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!

Word Macro VBA

Status
Not open for further replies.

send2mark

MIS
Nov 8, 2005
13
US
I'm making one of my first Macros and I found the script that I needed. I just can't get it to run when I open the template. It works when I go to the Macros and click on run, but not when I open the file.

Thanks

Sub SetSummaryInfo()
Dim dp As Object
If Documents.Count > 0 Then
Set dp = Dialogs(wdDialogFileSummaryInfo)
' Set "Title" to a new value.
dp.Title = "My Title"
' Set the value.
dp.Execute
' Save the changes.
ActiveDocument.Save
' Display the dialog.
' Note: Using the Display method will not keep changes
' manually entered into the dialog box. To keep changes
' manually entered in the dialog box, use the Show method.
dp.Display
End If
End Sub
 
There are probably several ways to achieve what you want. My usual way is put a pointer to the macro in Auto_Open. As in:
Code:
Sub Auto_Open()
    SetSummaryInfo
End Sub

_________________
Bob Rashkin
 
That is part of what I am looking for, but I can't get it to run when opening the .dot file. I'm thinking there is some other simple script that need to run also.
I was successfull with a different macro that I needed to add to the "ThisDocument." So I tried the same for this and it doesn't like that.
 
I used your code which was easier and changed AutoOpen to AutoNew and that worked for me. Thanks
 
You can also use Document_New().

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top