aidan.heritage@virgin.net
Guest
Re: Ghost Reference Part II
to use an existing or new instance of word as appropriate
Dim appwd As Object
On Error GoTo notloaded
Set appwd = GetObject(, "Word.Application")
notloaded:
If Err.Number = 429 Then
Set appwd = CreateObject("Word.Application")
End If
appwd.Visible = True
On Error GoTo 0
With appwd
then I would SUGGEST
Set MyDocument =appwd.open filename
at which point you are referencing the MyDocument variable and should
be fine!
pikapika13 wrote:
> I posted this question yesterday. Thank you Tom for responding. I
> should have been more clear on what I was looking for. Is there a VB
> script I can put in place IN CASE an instance of Word.exe is running?
> I would like the script to close it so it pulls in the correct
> instance. Thanks!
>
> Hello,
>
> I created a macro that opens up a .doc file after the user is asked to
> with Application.GetOpenFilename, and perform some actions. However,
> the macro seems to be using the wrong .doc file...a file that I used
> hours ago--NOT the one that I'm prompting excel to do.
> I just restarted my computer and now its using the correct file. Is
> there a script I can add to eliminate this?
>
> ******************************************************************************
> Possibly you have never successfully closed that instance of work due
> to a
> persistent reference. Before you run the code a second time, go into
> the
> task manager and see if Word.exe is already running.
>
>
> --
> pikapika13
> ------------------------------------------------------------------------
> pikapika13's Profile: http://www.excelforum.com/member.php...o&userid=10892
> View this thread: http://www.excelforum.com/showthread...hreadid=547062
Bookmarks