Documents.add error in Word 2003 macro

P

Patricia D

Macros worked OK in word 2002.
Since installing Office 2003 one macro can't get past this line
Documents.Add Template:=strUserFolder & strFileToOpen
I have stepped through macro and confirmed that strUserFolder and
strFileToOpen are valid values ("H:\My documents\Microsoft Templates\" and
"XP_fax.dot"). resulting error is
Runtime error '91'.
Object variable or With block variable not set.

If i manually open the ("XP_fax.dot") template document and run the macro
with above line, then everything is OK and a new document is added based on
required template.
Is this a security issue? I have set Tools/Macro/Security to Low to see if
that helped (it didn't)
 
J

Jezebel

I think you might be looking in the wrong place for the problem. That error
message doesn't relate directly to that line of code (ie, there is no object
reference to be causing a problem). Is there an AutoNew macro in XP_fax.dot,
or some code in XP_fax's ThisDocument module ? -- Given that the macro works
if the template is open, it sounds like there is code running in XP_fax
itself, and it's that code that's firing the error.
 
P

Patricia D

Yes, there is an Autonew macro in xp_fax.dot (no code in the ThisDocument
module), and at the fail stage a new document has been created using the
XP_Fax.dot template. But... I don't know how to find out what the problem is
- if I open the XP_Fax.dot template and run the AutoNew macro directly, it
runs OK.

When I get the fail, if I choose Debug although I can see the highlighted
line of code, as shown earlier, but I can't reset the project. Everything
freezes and I have to use the Task Manager to cancel Word or VBA.
 

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