none
SaveAs2 method still prompts. RRS feed

  • Question

  • Hi,

    I don't understand why I can't find the answer to this question online (maybe I can't search...)

    The problem is simple, I'm automating a Word 2010 document. Saving the document with the saveAs2 method and closing the document but the saveAs2 method still makes me prompt.

    Is it because I only filled the first 2 parameters?

    Is it because I enter the full path + the document's name in the fileName argument? If so where would I indicate the path?

    Thankss

    Here is my code : 

    Public Sub generateModel() Implements ModelGenerator.generateModel
    
            wordApp.Visible = True
            wordApp.DisplayAlerts = Word.WdAlertLevel.wdAlertsNone
    
            wordDoc = wordApp.Documents.Add
    
            wordDoc.PageSetup.TopMargin = wordApp.InchesToPoints(0.25)
            wordDoc.PageSetup.BottomMargin = wordApp.InchesToPoints(0.25)
            wordDoc.PageSetup.LeftMargin = wordApp.InchesToPoints(0.25)
            wordDoc.PageSetup.RightMargin = wordApp.InchesToPoints(0.25)
    
            With wordDoc.Content.Paragraphs.Add(wordDoc.Bookmarks.Item("\endofdoc").Range)
    
                .Range.Text = _text 
                .Format.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter
                .Format.LineUnitBefore = 1
                .Range.Font.SmallCaps = True
                .Range.Font.Size = 12
    
            End With
    
            Dim logo = wordDoc.Shapes.AddPicture(logoLoc)
            logo.Height = wordApp.InchesToPoints(0.5)
            logo.Width = wordApp.InchesToPoints(1.18)
    
            Me.mainTable = wordDoc.Tables.Add(wordDoc.Bookmarks.Item("\endofdoc").Range, 3, 2)
            mainTable.Rows.HeightRule = Word.WdRowHeightRule.wdRowHeightExactly
            mainTable.Columns.Width = wordApp.InchesToPoints(4)
            mainTable.Rows.Height = wordApp.InchesToPoints(3.25)
            mainTable.Select()
            wordApp.Selection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphLeft
    
            With wordDoc.Content.Paragraphs.Add(wordDoc.Bookmarks.Item("\endofdoc").Range)
    
                .Range.Text = "Rapport journalier de production - page 2"
                .Range.Font.Size = 10
                .Format.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter
                .Format.LineUnitBefore = 0
                .Format.SpaceBeforeAuto = False
                .Format.SpaceBefore = 0
    
            End With
    
            wordDoc.SaveAs2("C:\Doc1.docx")
    
            wordDoc.Close(False)
            wordApp.Application.Quit()
    
        End Sub
    ** Note that I've tried different paths and doc name.



    • Edited by SuperCorks Tuesday, February 26, 2013 1:43 PM
    Monday, February 25, 2013 2:59 PM

Answers

  • Finally we found the answer to the problem.

    It appears that if you install Word on an Acer computer, Acer will automatically install an Add-in to add AcerCloud functionality.

    This Add-in is the source of the bug. Deleting it solved our problem.


    • Edited by SuperCorks Tuesday, April 9, 2013 8:20 PM
    • Marked as answer by SuperCorks Tuesday, April 9, 2013 8:20 PM
    Tuesday, April 9, 2013 8:20 PM

All replies

  • Hi,

    Thank you for posting in the MSDN Forum.

    I've succeed in calling SaveAs2 method with only FileName parameter.

    Could you please show me your code? It's hard to make troubleshooting from words you've said.

    I look forward to your reply.

    Best regards,



    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, February 26, 2013 10:47 AM
    Moderator
  • Here you go. I inserted the code as you asked. I still don't understand, I even tried to fill all the parameters and it still does it. It's quite frustrating.

    And it doesn't do it with excel, which is even more frustrating.

    I tried the code on another machine and it works without problems. It appears that the problem is  my installation of Word. Could it be?

    Or is it because I'm windows 8?

    I'm so confused...

    • Edited by SuperCorks Tuesday, February 26, 2013 10:31 PM
    Tuesday, February 26, 2013 4:45 PM
  • Ok,

    after further inquiries, here's the state of my problem : 

    I built the release for a simple console application that had 3 lines : 

    Imports Microsoft.Office.Interop.Word
    Module Module1
    
        Sub Main()
    
            Try
                Dim s As New Application
    
                s.Documents.Add.SaveAs2(My.Application.Info.DirectoryPath & "\test.docx")
    
                s.Quit()
    
            Catch ex As Exception
                Console.WriteLine(ex.Message)
    
                Console.WriteLine(My.Application.Info.DirectoryPath & "\test.docx")
    
            End Try
    
            Console.ReadKey()
    
        End Sub
    
    End Module

    Now, when I run the app on my window 8 computer ( the one I use to code ) the app opens a new Ms word document, then it prompts me with the saveAs dialogbox (which should not happen), then it enters the Catch code block and finally wait's for a key before closing.

    When I run it on a windows XP (I did all the configuration for that), it opens the new Ms Word document and then I get a Windows dialog box that tells me the application had a problem and it should be closed. When I do close it, something appears in the console but it closes way to fast for me to read anything. ( So I'm guessing the try/catch bloc is not working )

    Is there an expert that could help me please? This is for my work and I'm starting to give up. Especially about the saveAs2 method problem, the try/catch thing I can probably handle my self...

    My version of word is 14.0 so the saveAs2 method should work fine.

    I'm using visual studio 2012

    .Net framework 4.0


    • Edited by SuperCorks Monday, March 4, 2013 4:19 PM
    Monday, March 4, 2013 4:04 PM
  • Hi SuperCorks,

    Sorry for the late in reply.

    I've noticed that you've replied to another thread which is similar to yours and tested in VBA project as well as console application project these days, but I never reproduce your scenario. 

    I've already contacted my colleague for suggestions, you'll be informed if there's any update.

    Thank you for your patience and understanding.

    Best regards,


    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, March 7, 2013 8:57 AM
    Moderator
  • Hi SuperCorks,

    It would seem we have the same SaveAs2 prompt problem although appearing on different Word versions. On my thread I now seem to have exhausted the resources of the MSDN Community Support with no solution in sight.

    In my latest post in my thread I’ve described a simple test concerning the DocumentBeforeSave event which clearly demonstrates a difference between a working and a nonworking Word.

    Would you please consider repeating this test on your system and tell me the result. My bet is that your system will fail similar to mine, but that remains to be seen. Don’t know if it’ll bring us any further though, but accurate information never hurts.  

    Tuesday, March 12, 2013 4:33 PM
  • Finally we found the answer to the problem.

    It appears that if you install Word on an Acer computer, Acer will automatically install an Add-in to add AcerCloud functionality.

    This Add-in is the source of the bug. Deleting it solved our problem.


    • Edited by SuperCorks Tuesday, April 9, 2013 8:20 PM
    • Marked as answer by SuperCorks Tuesday, April 9, 2013 8:20 PM
    Tuesday, April 9, 2013 8:20 PM