vb 打开word文件
请问有谁知道vb6.0中如何打开ProgramFiles目录下的word文件例如:要打开C:\ProgramFiles\a\a.doc我用Shell"C:\Program...
请问有谁知道vb6.0中如何打开Program Files目录下的word文件 例如:要打开C:\Program Files\a\a.doc我用Shell "C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE C:\Program Files\a\a.doc"打开是空白的word不是我指定的文件,可能是Program Files有空格的原因,请问用shell如何打开或者别的方式打开!
展开
2013-09-05
展开全部
请把以下代码贴到模块中: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")
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")
2013-09-05
展开全部
呵呵,你可以给文件地址加双引号。
如
shell "cmd ""c:\a.bat"""
如
shell "cmd ""c:\a.bat"""
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询