0

I'm searching for a way to preset the proposed filename in the SaveAs dialog of Ms Word 2010 from an COM AddIn. (Additionally I'd like to set also the default store path, but that is just secondary.)

I'm using the default SaveAs commandButton of the word, because the file should be stored in a SharePoint-Environment and the .Net SaveFileDialog doesn't support that. Code I'm using:

    var match = Application.CommandBars.FindControl(
                MsoControlType.msoControlButton, 748, null, null);
    match.Execute();

Things I've tried:

  • The Application.Document.Name and FullName properties only provide getters, so those are not available to set (why, I can't imagine).
  • Searching for the default FileName which can be set in the Word Settings (so set it to some value and then revert it later on)
  • Checked if there are other API operations available to set the document name.
  • A very dirty solution would be to store the document to a temp dir with the Document.SaveAs("fileName.doc") operation, so when executing the SaveAs button the name is already set.

Any ideas or solutions would be greatly appreciated.

Thanks, Chris

Nathan Hughes
  • 94,330
  • 19
  • 181
  • 276

1 Answers1

0

If I understood your question correctly, this worked for me. Using VS2010 & Office 2010

Microsoft.Office.Interop.Word._Document objWordDocument;
object objMissing = System.Reflection.Missing.Value;
objWordDocument = objWordApplication.Documents.Add(ref objMissing, ref objMissing, ref objMissing, ref objMissing);
objWordDocument.Activate();
objWordDocument.ActiveWindow.Caption = "CallMeWhatYouWill";
John Conde
  • 217,595
  • 99
  • 455
  • 496
CW1255
  • 113
  • 1
  • 1
  • 6