Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto insert Title from the file properties

Status
Not open for further replies.

send2mark

MIS
Nov 8, 2005
13
US
I have this template that prompts you to enter in the property information upon opening. Is there a way to take that info that they enter in those properties to go to designated bookmarks?

This is what I am using for the properties just incase you need to know.

Sub AutoNew()
Dialogs(wdDialogFileSummaryInfo).Show

End Sub
 
FileSummary of course does not give the full dialog for the Document Properties. However, if that is all you want...
Code:
Private Sub Document_New()
Dialogs(wdDialogFileSummaryInfo).Show

ActiveDocument.Bookmarks("Test").Range.Text = _
    ActiveDocument.BuiltInDocumentProperties(wdPropertyTitle)
    
End Sub
This would display the FileSummary dialog, then take the value of the Title property and put it in the bookmark Test.

Gerry
 
I had to change just a few things for this to work, like Document_New to AutoNew and then remove "Private". I'm not sure why I had to remove "Private", but that was the clincher at the end. Thank you so much for your help, this is huge for me.

I'm just curious about the File summary. You sounded like I was limiting myself.
 
I can't think of where I read it, but it is use for .dot creating a new .doc and Document_New() wasn't working for me.
 
If you are using a .DOT file to create a new document, then Document_New works. Please explain "wasn't working for me".

Document_New is generally now used, rather than AutoNew. It makes it explicit to the template.

Gerry
 
The macro doesn't run when I use Document_New. I can run it in Visual Basic, but not when I open the .DOT file. Does it matter that I am using Word 2003?
 
Uh..."open the .DOT file". Well of course it won't run when you open the .dot file. When you open the .dot file it is not making a new document. Document_Open would fire, but Document_New would not. However, that is NOT the way to use a template (.DOT) file.

Templates are (when they finally have their finished design) meant to be cloned - thus creating a new document. You do that with File > New and select the template. This creates a new, cloned, document. This makes Document_New fire.

Other than by the template designer, template files (.DOT) should NEVER be opened. If fact, good practice would have .DOT files read-only, AND have OS access permission levels set for just the designer.

Gerry
 
That makes sense. Earlier you mentioned about the Dialogs(wdDialogFileSummaryInfo).Show, was there something I should be doing differently with that one?
 
Oh, sorry. FileSummary is the only dislog you can display. HOWEVER, if you notice when you go File > Properties there are a bunch of other things. These are the BuiltInDocumentProperties. These are:

Title, Subject, Author, Keywords, Comments, Template, Last Author, Revision Number, Application Name, Last Print Date, Creation Date, Last Save Time, Total Editing Time, Number of Pages, Number of Words , Number of Characters, Security, Category, Format, Manager, Company, Number of Bytes, Number of Lines, Number of Paragraphs, Number of Slides, Number of Notes, Number of Hidden Slides, Number of Multimedia Clips.

NOTE: clearly there are properties that apply for some applications that do not apply for others. Calling one inappropriately will return an error.

You can access them with the DocumentProperties collection. You can also access CustomDocumentProperties - see the File > Properties dialog. Why you can not get a full dialog display.....who knows? Maybe there is a way that I am unaware of. However, you certainly can GET them. Look up BuiltInDocumentProperties in Help.

What I am saying is that if you want to, you can build your own dialog to get, and set, values that are displayed in File > Properties.

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top