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 Form_Load()
ShellExecute Me.hwnd, "open", "http://www.baidu.com", "", "", 1
End Sub
网址替换文件地址
vb如何对已经打开的word文件进行操作
首先引用 Microsoft word library
代码:
‘====================
Dim xWord As Word.Application
Private Sub CmdReplace_Click()
Dim xWord As Word.Application
Dim xRange As Range
Dim xSelection As Find
Dim xTabella As Table
Dim xCella As Cell
Set xWord = New Application
xWord.Visible = False
xWord.Documents.Add App.Path & "\新概念单词表3.rtf"
Set xRange = xWord.ActiveDocument.Range
xRange.Find.Execute "%%XXX%%", , , , , , , , , Text1.Text, True:
Set xRange = xWord.ActiveDocument.Range
xRange.Find.Execute "%%aaa%%", , , , , , , , , Text2.Text, True:
xWord.Visible = True
xWord.WindowState = wdWindowStateNormal
xWord.Application.Activate
End Sub
’================
‘"%%XXX%%" 、"%%aaa%%" 就是需要替换的内容
我的意思是先打开word再用vb操作。不是用vb打开。
VB怎么打开WORD文档
我看你直接用ole控件来打开就可以了
如何用VB打开word2007,例如桌面有个word2007文件,如何用VB打开
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()
Open "c:\新建文档.doc" For Output As #1 '打开一WORD文档
Print #1, "这是用VB新建的文档" '
Close
ShellExecute Me.hwnd, "open", "c:\新建文档.doc", vbNullString, vbNullString, 5
End
End Sub
vb中如何打开word文档
还是不太清楚,你是想在vb里调用office打开 还是在你的vb界面上显示word文档
路径不固定可以用dialog 控件打开 然后可以取到文件路径
vb怎么打开WORD文件?
发你百度消息。一句话简单 不用指明word安装目录就可打开
vb 打开word文件
请把以下代码贴到模块中:Private Declare Function GetDesktopWindow Lib "user32" () As LongPrivate 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 Const SW_SHOWNORMAL = 1Public Function OpenFile(asPath As String,optional PramCommand as string) As Long
On Error Resume Next
Dim Scr_hDC As Long
Scr_hDC = GetDesktopWindow()
If Len(asPath) = 0 Then Exit Function OpenFile = ShellExecute(Scr_hDC, "Open", asPath, PramCommand, "C:\", SW_SHOWNORMAL)
End Function 如果要打开word,直接调用Call OpenFile("C:\Program Files\a\a.doc")或者Call OpenFile(C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE,"C:\Program Files\a\a.doc")
VB.NET如何打开word文档
在窗体上放一个按钮,一个Webbrowser
简单代码如下,其他排错处理自己来:
PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.Click
DimopenAsNewOpenFileDialog
open.ShowDialog()
WebBrowser1.Navigate(open.FileName)
EndSub
效果如图:
转载请注明出处51数据库 » vb打开word文档 vb调用Word打开文档
名扬花满楼
