本文介绍了在VB.net创建Word实例时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我收到一个错误,当我在VS 2010中运行这个程序(正常工作在VS 2008中)
I am getting an error when I run this app in VS 2010 (it works fine in VS 2008)
私人小组GenerateInvoice()
Private Sub GenerateInvoice()
Dim emptyObject As Object = System.Reflection.Missing.Value
Dim wordApp As New Word.Application
wordApp.Visible = True
Dim InvoiceDoc As New Word.Document
InvoiceDoc = wordApp.Documents.Add(InvoicePath, emptyObject, emptyObject, emptyObject)
Dim totalFields As Integer = 0
For Each mergeField As Word.Field In InvoiceDoc.Fields
出现的错误在每行
The error occurs at the For Each line
对象未设置为一个 实例对象的。
我失去了一些东西呢?
推荐答案
也许 InvoicePath
在通过VS2010运行实例中使用是无效的,因此调用 Documents.Add
失败?
Maybe the InvoicePath
used in the instance run via VS2010 is invalid and so the call to Documents.Add
fails?
您在同一台机器上同时运行VS2010和VS2008?而在 InvoicePath
设置完全相同的路径在这两种情况?
Are you running both VS2010 and VS2008 on the same machine? And is the InvoicePath
set to the exact same path in both instances?
这篇关于在VB.net创建Word实例时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!