VB and Word
Posted on 2003-03-10
I'va a Visual Basic Application which opens a WordApp, adds a new doc and then fill the doc with many information provided by a db and the user can choose what will be inserted.
That all works perfect, and makes no problems. After the inserting-process word stays open to give the user a way to change the doc by himself and then save and close the doc. My vb App only opens up word, fills in the information and then does nothing else (but stays running)
When the user changes the doc (or close it unchanged, it makes no difference in the error) then i got an unhandled exception from word and the word instance stays open..
i does following to open a word doc:
dim WordApp as new Word.Application
dim MyDoc as Word.Document
set MyDoc = wordapp.add
' inserts the data
nothing else.. if i do the above code without filling in data, or only fill data like MyDoc.Range.Text = "blablabla" there's also no error
the exception cames from word and not from vb
can anyone help me with this error?
And is there any way to wait in the vb-app until word is closed again? (like modal?)
Thx for your help
!!!WOW!!! new Info: I've found out, that this exception only occurs, when the user doesn't save the doc. When he saves the doc, no error happens, but when i answers with "no" (word asks if it shall save the doc) word crashs, when i save word properly closes..