Word 2007 Macros

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to record a macro in Word 2007 that retreives a template as a new
document. For some reason, I can only get the macro to get the template as a
template. I don't know what I'm missing. Please help. Thanks.
 
I am trying to record a macro in Word 2007 that retreives a template as a new
document. For some reason, I can only get the macro to get the template as a
template. I don't know what I'm missing. Please help. Thanks.

I bet you're recording the use of the Open dialog. You should be using
the New dialog. If you do that, the macro should contain a statement
like this (but containing the name of the template you chose):

Documents.Add Template:= _
"C:\somePath\someTemplate.dotx" _
, NewTemplate:=False, DocumentType:=0

It should _not_ contain a Documents.Open statement, which is what
you're getting now.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
Jay Freedman said:
I bet you're recording the use of the Open dialog. You should be using
the New dialog. If you do that, the macro should contain a statement
like this (but containing the name of the template you chose):

Documents.Add Template:= _
"C:\somePath\someTemplate.dotx" _
, NewTemplate:=False, DocumentType:=0

It should _not_ contain a Documents.Open statement, which is what
you're getting now.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
Thanks for your reply -- the templates that I'm using were all are *.dot.
Should that matter?
 
Jay Freedman said:
I bet you're recording the use of the Open dialog. You should be using
the New dialog. If you do that, the macro should contain a statement
like this (but containing the name of the template you chose):

Documents.Add Template:= _
"C:\somePath\someTemplate.dotx" _
, NewTemplate:=False, DocumentType:=0

It should _not_ contain a Documents.Open statement, which is what
you're getting now.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

This is the syntax:

Sub GetLH()
'
' GetLH Macro
'
'
ChangeFileOpenDirectory "C:\WINWORD\TEMPLATE\"
Documents.Open FileName:="KohnLH.dot", ConfirmConversions:=True,
ReadOnly _
:=False, AddToRecentFiles:=False, PasswordDocument:="",
PasswordTemplate _
:="", Revert:=False, WritePasswordDocument:="",
WritePasswordTemplate:="" _
, Format:=wdOpenFormatAuto, XMLTransform:=""
Selection.MoveDown Unit:=wdLine, Count:=4
End Sub

I don't know what to do --
 
This is the syntax:

Sub GetLH()
'
' GetLH Macro
'
'
ChangeFileOpenDirectory "C:\WINWORD\TEMPLATE\"
Documents.Open FileName:="KohnLH.dot", ConfirmConversions:=True,
ReadOnly _
:=False, AddToRecentFiles:=False, PasswordDocument:="",
PasswordTemplate _
:="", Revert:=False, WritePasswordDocument:="",
WritePasswordTemplate:="" _
, Format:=wdOpenFormatAuto, XMLTransform:=""
Selection.MoveDown Unit:=wdLine, Count:=4
End Sub

I don't know what to do --

Delete the macro you have, since it doesn't do what you want. (In the
macro editor, just highlight all the code you showed above, and press
the Delete key.)

Start the macro recorder again. Click the Office button and choose the
item at the top of the menu, New, instead of the Open item.

If you see the KohnLH.dot template in the dialog, click it and click
the Create button. If you don't see that template in the dialog,
click the "My templates" choice in the list on the left side to get
another dialog. Choose the KohnLH.dot template in this dialog, and
click the OK button.

Stop the recorder. Try running the macro; it should make another new
document based on the same template.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top