从 COM 插件设置 MS Word 2010 文档名称
我正在寻找一种方法,通过 COM 加载项在 Ms Word 2010 的 SaveAs
对话框中预设建议的文件名。 (此外,我还想设置默认存储路径,但这只是次要的。)
我使用单词的默认 SaveAs
commandButton
,因为文件应存储在 SharePoint 环境中,而 .Net SaveFileDialog
不支持这一点。我正在使用的代码:
var match = Application.CommandBars.FindControl(
MsoControlType.msoControlButton, 748, null, null);
match.Execute();
我尝试过的事情:
Application.Document.Name
和FullName
属性仅提供 getter,因此这些属性无法设置(为什么,我无法想象)。- 搜索可以在 Word 设置中设置的默认
FileName
(因此将其设置为某个值,然后稍后恢复) - 检查是否有其他 API 操作可用于设置文档名称。
- 一个非常肮脏的解决方案是使用
Document.SaveAs("fileName.doc")
操作将文档存储到临时目录,因此在执行SaveAs
按钮时,名称已设置。
任何想法或解决方案将不胜感激。
谢谢, 克里斯
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
andFullName
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 theSaveAs
button the name is already set.
Any ideas or solutions would be greatly appreciated.
Thanks,
Chris
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我正确理解你的问题,这对我有用。使用VS2010&办公室2010
If I understood your question correctly, this worked for me. Using VS2010 & Office 2010