通过 vb6 重新打开 MS 文档时出错

发布于 2024-11-19 09:42:03 字数 1043 浏览 0 评论 0原文

我正在做一些 VB6 - MS WORD 应用程序..,这是我

dim WordObj As Word.Application
Dim objWord As Word.Document

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

第一次打开文件 PN.doc 并将其另存为 [name]-PN.doc 后的代码。效果很好。如果我重新打开它并重新保存它。出现错误,并显示

 The remote sever machine does not exist or is unavailable

当我尝试在 Word 应用程序中打开 PN.doc 时,会弹出错误并显示

the document has caused a serious error the last time it was opened. Would you like  to continue opening it?

我正在使用 Visual Basic6 和 MS Office 2010

tnx..,

I'm doing SOME VB6 - MS WORD application.., here's my code

dim WordObj As Word.Application
Dim objWord As Word.Document

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..,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

草莓味的萝莉 2024-11-26 09:42:03

ActiveDocument.Application.Quit

删除此行。您正在关闭 Word 两次。

ActiveDocument.Application.Quit

Remove this line. You are closing Word twice.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文