TIP: Click on subject to list as thread! ANSI
echo: visual_basic
to: All
from: Sean L.
date: 2004-06-10 21:56:00
subject: GetObject to find Word

I have created an app that uses Word automation to do a mail merge,
then display the finished product in a WebBrowser object on a form.  A
problem arises when the user already has an instance of Word running
when they start the program.  When the mail merge executes, the file
is opened in a new Word document.  To gain control of this document, I
use the GetObject method.  But, the Get Object method keeps returning
the instance of Word that was already running.  Is there any way to
distinguish between the two running instances of Word to the GetObject
method?

    'Use existing mrg file for mail merge
    wrdMailMerge.OpenDataSource MERGE_PATH
    wrdMailMerge.Destination = wdSendToNewDocument
    wrdMailMerge.Execute False
    
    'Close letter template
    wrdDoc.Close False
    Set wrdApp = Nothing
    
    'Get control of new document and save it in temporary file
    Set wrdApp = GetObject(, "Word.Application")
    Set wrdDoc = wrdApp.ActiveDocument

p.s. This works fine if Word is not already running.
---
þ RIMEGate(tm)/RGXPost V1.14 at BBSWORLD * Info{at}bbsworld.com

---
 * RIMEGate(tm)V10.2áÿ* RelayNet(tm) NNTP Gateway * MoonDog BBS
 * RgateImp.MoonDog.BBS at 6/10/04 9:56:51 PM
* Origin: MoonDog BBS, Brooklyn,NY, 718 692-2498, 1:278/230 (1:278/230)
SEEN-BY: 633/267 270
@PATH: 278/230 10/345 106/1 2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.