1

I am trying to change the proposed filename within the "Save As"-Dialog based on the content of a Content Control.

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

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.

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?

ashleedawg
  • 20,365
  • 9
  • 72
  • 105
Kaladorn
  • 11
  • 1

1 Answers1

1

I may have misunderstood

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

This yields "Asparagus"

And that is also the proposed FileName on save.

QHarr
  • 83,427
  • 12
  • 54
  • 101
  • The Title value changes as soon as i assign the objCC.Range.Text to it. But the proposed filename changes only the second time a klick the Save Button. – Kaladorn Mar 03 '18 at 21:07