1
votes

I have a word template that prompts the user for some text when opens a new document. I'm using the Fill-In field to do that and works fine. My question is: How can I reference the Fill-In field to assign the user text to Title of the document ?

I'm using this code, but it's not working:

With Dialogs(wdDialogFileSummaryInfo)
    .Title = Fillin
    .Execute
End With

Main goal here is: whatever the user writes on the prompt field when the document opens first time, will be the default filename of the word document when saving.

There is a better way to achieve this ? Thanks.

2

2 Answers

0
votes

This field code combination will assign what the user types into the Fill-in field to the Title property that provides the default file name for a new document:

{ TITLE { Fillin "Enter the document title" } }

It should display automatically when a new document is created from the template. As it stands, this will also display on the document surface. If you want it to be "hidden" you can nest the above in a SET field:

{ Set bkmTitle { TITLE { Fillin "Enter the document title" } } }

A Set field creates a bookmark, but the content is hidden for the user.

-1
votes

All you need is:

ActiveDocument.Fields.Update

In a Document_New macro in the 'ThisDocument' code module of the document's template.