操作WORD类时报错,高手请进...提示"未将对象引用设置到对象的实例"错误

tgc99 2006-11-06 11:10:54
建一个ASP.NET WEB应用程序.
添加引用WORD的COM组件

高手给看一下,运行到"oDocument.Activate()"的时候,提示"未将对象引用设置到对象的实例"错误


Dim newClass As New Class1
''''''''''''''''''''''''''''''''
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

''调用Class1类()
newClass.setNew()
newClass.NewDocWithModel("C:\InfoMod.doc")

End Sub
''''''''''''''''''''''''''''''''''
'''类模块
Public Class Class1
Private oWordApplic As Word.Application
Private oDocument As Word.Document
Public Sub setNew()
oWordApplic = New Word.Application
End Sub
Public Sub NewDocWithModel(ByVal FileName As String)
Dim missing = System.Reflection.Missing.Value
Dim isVisible As Boolean = True
Dim strName As String
strName = FileName

oDocument = oWordApplic.Documents.Add(strName, missing, missing, isVisible)
oDocument.Activate()
End Sub
End Class
...全文
242 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
jxzhang615 2006-11-06
  • 打赏
  • 举报
回复
帮顶
yagangshi 2006-11-06
  • 打赏
  • 举报
回复
沙发
tgc99 2006-11-06
  • 打赏
  • 举报
回复
就是WORD组件权限的问题.
tgc99 2006-11-06
  • 打赏
  • 举报
回复
TO dlzhangln(才高七八斗,学富五六车,改行三四次,月入一两千!) ::

你好,改成Dim strName As ojbect 之后还是报同样的错..
dlzhangln 2006-11-06
  • 打赏
  • 举报
回复
Public Sub NewDocWithModel(ByVal FileName As string)
Dim missing as ojbect = System.Reflection.Missing.Value
Dim isVisible As ojbect = True
Dim strName As ojbect
strName = FileName

oDocument = oWordApplic.Documents.Add(strName, missing, missing, isVisible)
oDocument.Activate()
End Sub
dlzhangln 2006-11-06
  • 打赏
  • 举报
回复
Public Sub NewDocWithModel(ByVal FileName As ojbect )
Dim missing as ojbect = System.Reflection.Missing.Value
Dim isVisible As ojbect = True
Dim strName As ojbect
strName = FileName

oDocument = oWordApplic.Documents.Add(strName, missing, missing, isVisible)
oDocument.Activate()
End Sub

16,555

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧