Re: Runtime 91 error for ActiveDocument in AutoExec macro
- From: "Jay Freedman" <jay.freedman@xxxxxxxxxxx>
- Date: Mon, 1 Oct 2007 11:20:14 -0400
I don't have any experience with Citrix, but if the connection is as slow as
your message seems to suggest, that in itself could be the cause. It might
also explain why some people see the error and others don't -- those that do
might just have a slower connection for some reason.
It might be possible in your AutoExec macro to use an On Error trap in a
loop, so that the first access to ActiveDocument is retried until it
succeeds or there have been a specified number of unsuccessful tries (or
until a specified time has elapsed). Be sure to allow some exit condition of
this sort, so the loop doesn't lock up the application for an extended
period.
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
proashu wrote:
Thanks Jay.
The additional delay of few seconds might not be desirable to our
business. This is happening over a Citrix connection, and additonal
delay is not good.
My recent findings indicate that -
When I try to look at the MS Word installs for the people who are
affected by the Runtime error,
I do not see any addins in the startup folder.
I do not see any COM Addins as well.
So I am not sure what else would cause the ActiveDocument not to
load before my AutoExec logic fires off, and throw a Runtime 91 error
when I invoke ActiveDocument.bookmarks
Is there anything else that you can think of that can cause the
loading of the document to be delayed ?
"Jay Freedman" wrote:
The AutoExec macro starts running as soon as Word loads, which may
be before there is any document loaded into the workspace. I'd guess
that the difference between the two situations -- working vs.
failing -- may depend on just how long it takes for the document to
load, which in turn may depend on whether an add-in like Acrobat
Writer is loading first, or on whether the document is stored
locally or across the network.
You might be able to work around this with the OnTime technique in
http://word.mvps.org/faqs/userforms/AutoExecUsertFm.htm.
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
proashu wrote:
I am trying to invoke MS word in the following manner:
start winword.exe /lc:\glb\myglobal.dot /tc:\tmp\doctemplate.dot /
myglobal.dot -
My global template - contains the following logic
Public Sub AutoExec()
If ActiveDocument.Bookmarks.Exists("CSWB") Then If (InStr(1,
ActiveDocument.FullName, ".rtf") < 1) Then
ActiveDocument.RunAutoMacro (wdAutoNew)
End if
End If
doctemplate.dot -
A document template that contains the AutoNew macro defined.
Problem scenario:
When I run - "start winword.exe /lc:\glb\myglobal.dot
/tc:\tmp\doctemplate.dot /" from command prompt it works fine.
I install Adobe Acrobat writer on my machine, and run the same
command,
It fails with a Runtime 91 error - Object variable not set
Looks like ActiveDocument object is not initialized and fails when I
try to access ActiveDocument.Bookmarks collection.
When I uninstall Adobe acrobat writer, the problem goes away.
This is happening in production as well (that actually triggered
this analysis) but I don't necessarily see Adobe writer installed in
production. Is there anything else that when installed would change
the behaviour of AutoExec as I have mentioned ?
If you have any ideas as to how can I avoid this, that would be
great.
.
- Follow-Ups:
- References:
- Prev by Date: Re: Print a specific part of document
- Next by Date: Re: Print a specific part of document
- Previous by thread: Re: Runtime 91 error for ActiveDocument in AutoExec macro
- Next by thread: Re: Runtime 91 error for ActiveDocument in AutoExec macro
- Index(es):
Relevant Pages
|