error on reopening a ms document via vb6
I'm doing SOME VB6 - MS WORD application.., here's my code
dim WordObj As Word.Application
Dim objWord As Word.Document
开发者_JS百科
Set WordObj = new Word.Application
Set objWord = WordObj.Documents.Open(FileName:=App.Path & "\PN.doc")
With objWord.Bookmarks
.Item("NAME").Range.Text = name.Text
.Item("ADDRESS").Range.Text = add.Text
.Item("ID").Range.Text = id.Text
.Item("PHONE").Range.Text = phone.Text
.Item("FAX").Range.Text = fax.Text
End With
ActiveDocument.SaveAs (App.Path & "\" & name.text & "-PN.Doc")
ActiveDocument.Application.Quit
WordObj.Quit False
Set WordObj = Nothing
Set objWord = Nothing
after 1st opening on the file PN.doc and save it as [name]-PN.doc. it works fine. if I reopen it and re save it. an error came up and says
The remote sever machine does not exist or is unavailable
when i try to open the PN.doc in a word application, an error will pup-out and says
the document has caused a serious error the last time it was opened. Would you like to continue opening it?
im using visual basic6 and ms office 2010
tnx..,
ActiveDocument.Application.Quit
Remove this line. You are closing Word twice.
精彩评论