none
ActiveDocument.SaveAs2 Does NOT Work - 1. Shows Prompt 2. Returns 'Run-time Error 4198: Command Failed' RRS feed

  • Question

  • Hey All,

    So I am beyond frustrated, ActiveDocument.SaveAs2 will not work correctly.

    1. When calling ActiveDocument.SaveAs2 the SaveAs Dialog Prompt appears (<- the entire reason for said function)

    2. Canceling or Saving from within the prompt that appears (that should not appear) causes an Exception in my Excel automation resulting in 'Run-time Error 4198: Command Failed'

    This is silly.

    Have been doing Excel/Word automation since Office 2005 without any issues performing this exact functionality, lo an behold Win8 + Office 2013 = BROKEN. (At home with Win7 + Office 365 works FINE)

    DEV ENV: Windows 8 (x64) and Office 2013 Professional Plus.
    (This issue occurs on multiple machines from different Manufacturers)

    I have tried removing any extra Add-In's or potentially conflicting software, tried using different versions of document formats, tried saving to different locations, tried all solutions posted here, all to no avail.

    Quick summary of automation.

    1. Create Word.Application object.
    2. Add/Open pre-existing Word Doc Template (.dotx)
    3. Merge data from Excel using Word Bookmarks
    4. Automatically save copy of Document (<- ISSUE)
    5. Export PDF version of Document (<- ISSUE)

    CODE EXCERPT:

        Set wdApp = CreateObject("Word.Application")    
        Set wdDoc = wdApp.Documents.Add(ThisWorkbook.Path & "\Report_Template.dotx")
    	
    	...	
    	
        With wdApp.ActiveDocument
    		Dim SavePath As String: SavePath = ThisWorkbook.Path & "\" & ReportName & ".dotx"
            .SaveAs2 SavePath
        End With

    Any help would be GREATLY appreciated!!

    Thanks!


    Monday, March 18, 2013 11:43 PM

Answers

  • I know you've been pointed at

    http://social.msdn.microsoft.com/Forums/en-US/worddev/thread/1b8282a5-1c3f-41d4-93dd-39d084fad13d/

    in your duplicate thread for Excel.

    However, I encourage you to read MY reply in that thread once more.

    From the discussion in the other thread, it's clear that SaveAs2 does work in Word, so it's not broken. The three people with the problem participating in that thread all agree that the issue was caused by a third-party add-in. I urge you to check your system for any add-ins that are running in Office or Windows. The add-in does not necessarily have to be the one that those other three found was causing the problem on their systems.


    Cindy Meister, VSTO/Word MVP, my blog

    Tuesday, March 19, 2013 9:33 AM
    Moderator

All replies

  • Hey All,

    So I am beyond frustrated, ActiveDocument.SaveAs2 will not work correctly.

    1. When calling ActiveDocument.SaveAs2 the SaveAs Dialog Prompt appears (<- the entire reason for said function)

    2. Canceling or Saving from within the prompt that appears (that should not appear) causes an Exception in my Excel automation resulting in 'Run-time Error 4198: Command Failed'

    This is silly.

    Have been doing Excel/Word automation since Office 2005 without any issues performing this exact functionality, lo an behold Win8 + Office 2013 = BROKEN. (At home with Win7 + Office 365 works FINE)

    DEV ENV: Windows 8 (x64) and Office 2013 Professional Plus.
    (This issue occurs on multiple machines from different Manufacturers)

    I have tried removing any extra Add-In's or potentially conflicting software, tried using different versions of document formats, tried saving to different locations, tried all solutions posted here, all to no avail.

    Quick summary of automation.

    1. Create Word.Application object.
    2. Add/Open pre-existing Word Doc Template (.dotx)
    3. Merge data from Excel using Word Bookmarks
    4. Automatically save copy of Document (<- ISSUE)
    5. Export PDF version of Document (<- ISSUE)

    CODE EXCERPT:

        Set wdApp = CreateObject("Word.Application")    
        Set wdDoc = wdApp.Documents.Add(ThisWorkbook.Path & "\Report_Template.dotx")
    	
    	...	
    	
        With wdApp.ActiveDocument
    		Dim SavePath As String: SavePath = ThisWorkbook.Path & "\" & ReportName & ".dotx"
            .SaveAs2 SavePath
        End With

    Any help would be GREATLY appreciated!!

    Thanks!

    Monday, March 18, 2013 11:45 PM
  • Hi RecursiveHook,

    Perhaps you can find useful infomation in 

    Can not get he ActiveDocument.SaveAs2 method to work on Word 2013

    HTH


    with regards, Yuri

    Tuesday, March 19, 2013 1:46 AM
  • Thanks, however I already read through it, does not fix anything.
    Tuesday, March 19, 2013 1:50 AM
  • I know you've been pointed at

    http://social.msdn.microsoft.com/Forums/en-US/worddev/thread/1b8282a5-1c3f-41d4-93dd-39d084fad13d/

    in your duplicate thread for Excel.

    However, I encourage you to read MY reply in that thread once more.

    From the discussion in the other thread, it's clear that SaveAs2 does work in Word, so it's not broken. The three people with the problem participating in that thread all agree that the issue was caused by a third-party add-in. I urge you to check your system for any add-ins that are running in Office or Windows. The add-in does not necessarily have to be the one that those other three found was causing the problem on their systems.


    Cindy Meister, VSTO/Word MVP, my blog

    Tuesday, March 19, 2013 9:33 AM
    Moderator