在另存为对话框中更改默认文件名 [英] Change default filename in SaveAs Dialog
问题描述
我试图根据内容控件的内容在"Save As
"-对话框中更改建议的文件名.
I am trying to change the proposed filename within the "Save As
"-Dialog based on the content of a Content Control.
我的理解是Word在SaveAs
对话框中提出了文档属性"Title
".
My understanding was that Word is proposing the Document Property „Title
" within the SaveAs
Dialog.
在一个空文档中,我创建了一个内容控件(仅文本),并将以下代码放在此文档"中.
Within an empty Document I created a Content Control (Text only) and put the following code in "This Document".
Private Sub Document_ContentControlOnExit(ByVal objCC As ContentControl, _
Cancel As Boolean)
ActiveDocument.BuiltInDocumentProperties("Title") = objCC.Range.Text
End Sub
内置属性"Title
"在休假时按预期进行了更改,但是按另存为"按钮并没有更改建议的文件名.
取消"SaveAs
"对话框并再次打开它(在这之间没有任何其他动作),建议将新"标题作为默认文件名.
The built-in Property "Title
" changed on leave as expected but pressing the Save As Button did not change the proposed filename.
Cancelling the "SaveAs
"-Dialog and opening it once again (without any other actions in between) the "new" Title was proposed as default filename.
过程:
1.将标题更改为新文件名"
2.按另存为->建议的文件名"Doc1"
3.取消另存为
4.按另存为->建议的文件名新文件名"
5.将标题更改为更好的文件名"
6.按另存为->建议的文件名新文件名"
7.取消另存为
8.按另存为->建议的文件名更好的文件名"
Process:
1. Change Title to „New Filename"
2. Press Save As -> Proposed Filename „Doc1"
3. Cancel Save As
4. Press Save As -> Proposed Filename „New Filename"
5. Change Title to „Better Filename"
6. Press Save As -> Proposed Filename „New Filename"
7. Cancel Save As
8. Press Save As -> Proposed Filename „Better Filename"
...
此功能"是否有解决方法?还是我错了?
Is there a Workaround to this "Feature" or am I just wrong?
推荐答案
我可能误会了
Sub test()
Dim objCC As ContentControl
Set objCC = ActiveDocument.ContentControls.Add(wdContentControlText)
objCC.Range.Text = "Asparagus"
End Sub
Private Sub Document_ContentControlOnExit(ByVal objCC As ContentControl, Cancel As Boolean)
MsgBox ActiveDocument.BuiltInDocumentProperties("Title")
End Sub
这将产生芦笋"
这也是保存时建议的FileName.
And that is also the proposed FileName on save.
这篇关于在另存为对话框中更改默认文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!