从COM加载项设置MS Word 2010文档名称

从COM加载项设置MS Word 2010文档名称,com,ms-word,add-in,document,Com,Ms Word,Add In,Document,我正在搜索一种方法,从COM插件在Ms Word 2010的SaveAs对话框中预设建议的文件名。(此外,我还想设置默认存储路径,但这只是次要的。) 我使用的是word的默认SaveAscommandButton,因为文件应该存储在SharePoint环境中,而.NetSaveFileDialog不支持这一点。我正在使用的代码: var match = Application.CommandBars.FindControl( MsoControlType.

我正在搜索一种方法,从COM插件在Ms Word 2010的
SaveAs
对话框中预设建议的文件名。(此外,我还想设置默认存储路径,但这只是次要的。)

我使用的是word的默认
SaveAs
commandButton
,因为文件应该存储在SharePoint环境中,而.Net
SaveFileDialog
不支持这一点。我正在使用的代码:

    var match = Application.CommandBars.FindControl(
                MsoControlType.msoControlButton, 748, null, null);
    match.Execute();
我尝试过的事情:

  • Application.Document.Name
    FullName
    属性只提供getter,因此无法设置它们(为什么,我无法想象)
  • 搜索可在Word设置中设置的默认
    文件名
    (因此将其设置为某个值,然后稍后再还原)
  • 检查是否有其他API操作可用于设置文档名称
  • 一个非常糟糕的解决方案是使用
    document.SaveAs(“fileName.doc”)
    操作将文档存储到临时目录,因此在执行
    SaveAs
    按钮时,名称已经设置好
任何想法或解决方案都将不胜感激

谢谢,
克里斯

如果我正确理解了你的问题,这对我很有用。使用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";