ChangeFileOpenDirectory not changing path in Word 'SaveAs' dialog RRS feed

  • Question

  • We have developed a VSTO Word AddIn for Word 2010 (32-bit Office).

    Within this add-in, we are intercepting a 'Before SaveAs event', that is, before Word displays the 'Save as' dialog.

    We are using the Application.ChangeFileOpenDirectory method (Word) to the alter the path that 'Save as' dialog will suggest. We have also tried to set the Options.DefaultFilePath property, without success.

    In the first test scenario, when we start Word 2010 from the Start menu, and then select 'Save as', the dialog will show the path passed to ChangeFileOpenDirectory - as expected!

    However, when we start Word 2010 through a double-click on a document from C:\tmp, for instance, ChangeFileOpenDirectory does not seem to work, the dialog will wrongly show C:\tmp instead of the path passed to ChangeFileOpenDirectory

    We need a reliable way to set the path before the 'Save as', the dialog will show.

    Our test system:
    Windows 7 Enterprise, SP1, Build 7601
    Word 2010, 14.0.7173.5000 (32-Bit)

    Any suggestions? Thanks!
    Tuesday, October 18, 2016 12:51 PM

All replies

  • Hi Alpensturm,

    What do you mean by “Before SaveAs event”? Do you mean DocumentBeforeSave?

    I suggest you try below code:

            void Application_DocumentBeforeSave(Word.Document Doc, ref bool SaveAsUI, ref bool Cancel)
                //disable built-in save as function
                SaveAsUI = false;
                Cancel = true;
                Dialog d = Application.Dialogs[WdWordDialog.wdDialogFileSaveAs];
                object oDlg = (object)d;
                object[] oArgs = new object[1];
                oArgs[0] = (object)@"D:\work\xx";
                oDlg.GetType().InvokeMember("Name", BindingFlags.SetProperty, null, oDlg, oArgs);
                d.Show(ref missing);            

    You could refer the link below for more information.

    # ChangeFileOpenDirectory not changing path in Word 'SaveAs' dialog

    Best Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, October 19, 2016 8:15 AM