感谢您使用微软产品。您可以使用OLE Automation来调用Word,以下有一篇文章您可以参考一下:
How to Use (OLE) Automation with Word
(http://support.microsoft.com/support/kb/articles/Q184/9/74.ASP)- 微软亚洲技术中心 VB技术支持本贴子仅供CSDN的用户作为参考信息使用。其内容不具备任何法律保障。您需要考虑到并承担使用此信息可能带来的风险。具体事项可参见使用条款 (http://www.csdn.net/microsoft/terms.shtm)。
How to Use (OLE) Automation with Word
(http://support.microsoft.com/support/kb/articles/Q184/9/74.ASP)- 微软亚洲技术中心 VB技术支持本贴子仅供CSDN的用户作为参考信息使用。其内容不具备任何法律保障。您需要考虑到并承担使用此信息可能带来的风险。具体事项可参见使用条款 (http://www.csdn.net/microsoft/terms.shtm)。
解决方案 »
- vb调用存储过程,执行过程中遇到,实时错误'-2147217900(80040e4)',怎么办?
- 关于获取网卡地址的问题 问题解决马上给分
- 好苦,我的技术员走啦连我的网站全删除,他带走的是他的贸易软件系统和所有的网站,现在客户要我陪我该怎么办?
- 请问vb6里面的ado datagrid控件可以拿到vb5里面使用吗?
- 如何解决用DataGrid控件来显示过多记录太慢
- 如何用循环使菜单编辑器中的菜单不可见?
- vb和xml的问题?(急)
- 集合的功能
- 在线等待!!!高分求救!!!!!!!!!!!!!
- 如何用VS连接SQL
- 很简单的Active EXE 问题
- 怎么样才能使label上的字体,在鼠标移在上面时,发生变化,移走时恢复。
Dim Doc As New Document
Dim Visi As Boolean'拼写检查
Private Sub Command1_Click()
Form1.Caption = "拼写检查"
Doc.Range.Text = Text1
'确定范围
Doc.Application.Visible = True '将Word 97变为可见
AppActivate Doc.Application.Caption
'激活Word 97
Call CheckSpell(Text1.Text) '拼写检查
Text1 = Doc.Range.Text
Text1 = Left(Text1, Len(Text1) - 1)
AppActivate Caption
End Sub'统计单词数
Private Sub Command2_Click()
Dim Dlg As Word.Dialog
Doc.Range = Text1.Text
Set Dlg = Doc.Application.Dialogs(wdDialogDocumentStatistics)
Dlg.Execute '统计单词和字符
Form1.Caption = "单词数:" & Str(Dlg.Words) & "词" & Str(Dlg.Characters) & "字符" '显示统计结果
End SubPrivate Sub Form_Load()
Form1.Caption = "调用Word 97"
Text1.Text = ""
Command1.Caption = "拼写检查"
Command2.Caption = "统计单词"
'使应用程序可见
'‘Visi = Doc.Application.Visible
End Sub'关闭应用程序
Private Sub Form_Unload(Cancel As Integer)
If Visi Then '关闭文件
Doc.Close savechanges:=False
Else
Doc.Application.Quit savechanges:=False '关闭 Word 97
End If
End SubFunction CheckSpell(IncorrectText As String) As String
Dim Word As Object, retText$
On Error Resume Next
'建立对象并打开 WORD
Set Word = CreateObject("Word.Basic")
'把需要检查的 STRING 放到 WORD
Word.AppShow
Word.FileNew
Word.Insert IncorrectText
'运行 WORD 拼写检查
Word.ToolsSpelling
Word.EditSelectAll
'取返回值
retText = Word.Selection$()
CheckSpell = Left$(retText, Len(retText) - 1)
'关闭文件并回到 VB 应用
Word.FileClose 2
Show
Set Word = Nothing
End Function
Dim Doc As New Document
Dim Visi As Boolean'拼写检查
Private Sub Command1_Click()
Form1.Caption = "拼写检查"
Doc.Range.Text = Text1
'确定范围
Doc.Application.Visible = True '将Word 97变为可见
AppActivate Doc.Application.Caption
'激活Word 97
Call CheckSpell(Text1.Text) '拼写检查
Text1 = Doc.Range.Text
Text1 = Left(Text1, Len(Text1) - 1)
AppActivate Caption
End Sub'统计单词数
Private Sub Command2_Click()
Dim Dlg As Word.Dialog
Doc.Range = Text1.Text
Set Dlg = Doc.Application.Dialogs(wdDialogDocumentStatistics)
Dlg.Execute '统计单词和字符
Form1.Caption = "单词数:" & Str(Dlg.Words) & "词" & Str(Dlg.Characters) & "字符" '显示统计结果
End SubPrivate Sub Form_Load()
Form1.Caption = "调用Word 97"
Text1.Text = ""
Command1.Caption = "拼写检查"
Command2.Caption = "统计单词"
'使应用程序可见
'‘Visi = Doc.Application.Visible
End Sub'关闭应用程序
Private Sub Form_Unload(Cancel As Integer)
If Visi Then '关闭文件
Doc.Close savechanges:=False
Else
Doc.Application.Quit savechanges:=False '关闭 Word 97
End If
End SubFunction CheckSpell(IncorrectText As String) As String
Dim Word As Object, retText$
On Error Resume Next
'建立对象并打开 WORD
Set Word = CreateObject("Word.Basic")
'把需要检查的 STRING 放到 WORD
Word.AppShow
Word.FileNew
Word.Insert IncorrectText
'运行 WORD 拼写检查
Word.ToolsSpelling
Word.EditSelectAll
'取返回值
retText = Word.Selection$()
CheckSpell = Left$(retText, Len(retText) - 1)
'关闭文件并回到 VB 应用
Word.FileClose 2
Show
Set Word = Nothing
End Function
dim WordDoc as Word.Documents
set WordApp=new Word.Applicton
wordapp.visible=true
set worddoc=wordapp.document.add