B
Billy Chan
background: In access, I'm looping through a recordset to
populate generate Word documents (one per row)
problem: after calling doc.saveAs([filename]) and then
doc.close, my Word object becomes 'unhinged'
here's a snippet of code:
Dim objWord As Word.Application
Dim objDoc As Word.Document 'Document Object
Set objWord = CreateObject("Word.Application")
While Not rsSource.EOF
set objDoc = objWord.Documents.Add
' skipping actual formfield populating code
objDoc.saveAs strFilename
objDoc.close
rsSource.MoveNext
wend
watching the local variables, I see objWord = "Microsoft
Word" up until I call objDoc.close.
If I add objWord.Visible = True
I can even see my documents being populated and then when
closing the doc, Word app itself also quits.
I've even tried opening up a second temporary doc so that
it'll stick around but with Visible=True, I see that both
docs get closed.
Any help would be appreciated.
Thanks
Billy
populate generate Word documents (one per row)
problem: after calling doc.saveAs([filename]) and then
doc.close, my Word object becomes 'unhinged'
here's a snippet of code:
Dim objWord As Word.Application
Dim objDoc As Word.Document 'Document Object
Set objWord = CreateObject("Word.Application")
While Not rsSource.EOF
set objDoc = objWord.Documents.Add
' skipping actual formfield populating code
objDoc.saveAs strFilename
objDoc.close
rsSource.MoveNext
wend
watching the local variables, I see objWord = "Microsoft
Word" up until I call objDoc.close.
If I add objWord.Visible = True
I can even see my documents being populated and then when
closing the doc, Word app itself also quits.
I've even tried opening up a second temporary doc so that
it'll stick around but with Visible=True, I see that both
docs get closed.
Any help would be appreciated.
Thanks
Billy