+ Reply to Thread
Results 1 to 2 of 2

Ghost Reference Part II

  1. #1
    Forum Contributor
    Join Date
    06-21-2004
    Posts
    106

    Ghost Reference Part II

    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.

  2. #2
    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



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1