macro to open template or document in 2007

S

Sara

I have templates and documents that I would like to set up a macro to open. I
was able to do this in an older version of Word but haven't been able to
figure it out for 2007. I can probably enter programming if someone gives it
to me, but I am using record to create macros. Thanks!
 
S

Sara

Before, I would go into the macro code and paste in the whole path, if it
didn't work by just opening the document while using macro record. I just
tried a macro I had tried to create and it gave me: Run-time error '5491':
The requested member of the collection does not exist. I suspect there is
some special code to use to open the template as I would by going into
file>new, so it will open as a new document.

Code for macro that gave me that error:

Sub infop()
'
' infop Macro
'
'
Windows("4-16-03 Agenda.doc [Compatibility Mode]").Activate
ActiveWindow.Panes(1).Activate
Windows("Document6 [Compatibility Mode]").Activate
ActiveWindow.Panes(1).Activate
Documents.Add Template:= _
"C:\Documents and Settings\Sara.MOBAR\Application
Data\Microsoft\Templates\infop form.dot" _
, NewTemplate:=False, DocumentType:=0
End Sub
 
T

Tony Jollans

My guess is that one of the documents you are trying to Activate isn't
currently open.

Technically the Activates, the first four lines of your code, don't do
nothing, but their effect in almost all circumstances is irrelevant. Remove
them.

All that's then left is the creation of a new document based on the template
you specify; assuming it exists I see nothing wrong in the code - but that
isn't opening either an existing document or template, so I'm a bit confused
about your original question.

--
Enjoy,
Tony

www.WordArticles.com

Sara said:
Before, I would go into the macro code and paste in the whole path, if it
didn't work by just opening the document while using macro record. I just
tried a macro I had tried to create and it gave me: Run-time error '5491':
The requested member of the collection does not exist. I suspect there is
some special code to use to open the template as I would by going into
file>new, so it will open as a new document.

Code for macro that gave me that error:

Sub infop()
'
' infop Macro
'
'
Windows("4-16-03 Agenda.doc [Compatibility Mode]").Activate
ActiveWindow.Panes(1).Activate
Windows("Document6 [Compatibility Mode]").Activate
ActiveWindow.Panes(1).Activate
Documents.Add Template:= _
"C:\Documents and Settings\Sara.MOBAR\Application
Data\Microsoft\Templates\infop form.dot" _
, NewTemplate:=False, DocumentType:=0
End Sub


Tony Jollans said:
What did you do before? And what about it doesn't work in 2007?

--
Enjoy,
Tony

www.WordArticles.com
 
S

Sara

I want to use a macro to open the infop form.dot document as it would if I
went to file>new and clicked on that template. It would open that template
as Document7.doc (or whatever number).

It looks like removing those 4 lines of code has done the trick. Thanks!


Tony Jollans said:
My guess is that one of the documents you are trying to Activate isn't
currently open.

Technically the Activates, the first four lines of your code, don't do
nothing, but their effect in almost all circumstances is irrelevant. Remove
them.

All that's then left is the creation of a new document based on the template
you specify; assuming it exists I see nothing wrong in the code - but that
isn't opening either an existing document or template, so I'm a bit confused
about your original question.

--
Enjoy,
Tony

www.WordArticles.com

Sara said:
Before, I would go into the macro code and paste in the whole path, if it
didn't work by just opening the document while using macro record. I just
tried a macro I had tried to create and it gave me: Run-time error '5491':
The requested member of the collection does not exist. I suspect there is
some special code to use to open the template as I would by going into
file>new, so it will open as a new document.

Code for macro that gave me that error:

Sub infop()
'
' infop Macro
'
'
Windows("4-16-03 Agenda.doc [Compatibility Mode]").Activate
ActiveWindow.Panes(1).Activate
Windows("Document6 [Compatibility Mode]").Activate
ActiveWindow.Panes(1).Activate
Documents.Add Template:= _
"C:\Documents and Settings\Sara.MOBAR\Application
Data\Microsoft\Templates\infop form.dot" _
, NewTemplate:=False, DocumentType:=0
End Sub


Tony Jollans said:
What did you do before? And what about it doesn't work in 2007?

--
Enjoy,
Tony

www.WordArticles.com

I have templates and documents that I would like to set up a macro to
open.
I
was able to do this in an older version of Word but haven't been able
to
figure it out for 2007. I can probably enter programming if someone
gives
it
to me, but I am using record to create macros. Thanks!
 

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

Top