关于用VB.NET打开指定word文档
关于这个问题,我看了几个相关问题,但还是有几点不明白的地方,在这里请教各位高手:第一,在下面这段代码中,如何“在工具菜单中引用Microsoft Word10.0 Object Library”?
'要在工具菜单中引用Microsoft Word10.0 Object Library
Dim wdApp As New Word.Application
Dim doc, doc1 As Word.Document
Dim s As Word.Selection
Set doc1 = Documents.Open("E:\Sample.doc") '打开一个文档
'Set doc = wdApp.Documents.Add '新建一个文档
wdApp.Visible = True '使Word窗口可见
Set s = wdApp.Selection
s.TypeText "在新开的文档中增加一段文字" '在新建文档插入一段文字
doc.SaveAs "E:\Sample1.doc" '保存新建的文档
wdApp.Quit '退出Word
Set wdApp = Nothing
第二,下面这段代码中,如何声明re 和 hwnd ?
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Sub Command1_Click()
re = ShellExecute(Me.hwnd, "Open", "c:\aa.doc", "", App.Path, 1)
End Sub
多谢各位好心的高手回复!
--------------------编程问答-------------------- 请求回复。。。。。。 --------------------编程问答-------------------- 一、
项目->引用->添加引用对话框->COM->Microsoft Word XX.0 Object Library
二、
使用Microsoft.VisualBasic.Shell就可以了 --------------------编程问答-------------------- 多谢多谢!!!!!!!!!!!!!
补充:.NET技术 , VB.NET