Prevent opening another window

orna

Registered User.
Local time
Today, 16:13
Joined
Oct 13, 2002
Messages
78
Hi
I have this code to build a report in Word from Access, my problem is that
evry time i run it, it opens a new Word instance.
Is there any way to open new Word only if it's not opened?

Set qdf = CodeDb.QueryDefs("Comp")
Set rst = qdf.OpenRecordset()
Set objword = GetObject("", "Word.Application")
Do Until rst.EOF
With objword
.Visible = True
.Documents.Add Template:=("\\Ilis\Complaints\Complaint.dot")
.Selection.GoTo Name:=("CurrentID")
.Selection.TypeText Text:=rst![CurrentID]
.
.
.
End With
rst.MoveNext
Loop

TIA :confused:
 
From VBA help on GetObject:
If pathname is a zero-length string (""), GetObject returns a new object instance of the specified type. If the pathname argument is omitted, GetObject returns a currently active object of the specified type. If no object of the specified type exists, an error occurs.
 
Thanks RuralGuy !!

I missed that
 

Users who are viewing this thread

Back
Top Bottom