English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

例如:桌面上一個123.doc的檔案 有辦法用VB開啟嗎?

2005-11-22 15:09:13 · 3 個解答 · 發問者 Anonymous in 電腦與網際網路 程式設計

3 個解答

Option Explicit

Private Const MAX_PATH = 2048
Private Const CSIDL_DESKTOP = &H0&

Private Declare Function SHGetSpecialFolderLocation Lib "Shell32" (ByVal hWndOwner As Long, ByVal nFolder As Integer, ppidl As Long) As Long
Private Declare Function SHGetPathFromIDList Lib "Shell32" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal szPath As String) As Long

Private Const SW_SHOW = 5
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()
Dim ppidl As Long, strDesktopPath As String

strDesktopPath = String(MAX_PATH, 0)

'因為Windows的版本不同,桌面的路徑就不一樣。
'可以下面兩個API函數取得桌面的路徑
SHGetSpecialFolderLocation Me.hWnd, CSIDL_DESKTOP, ppidl
SHGetPathFromIDList ppidl, strDesktopPath

strDesktopPath = Left(strDesktopPath, InStr(strDesktopPath, Chr(0)) - 1)

'開啟桌面的doc檔案
ShellExecute Me.hWnd, "open", strDesktopPath & "\123.doc", vbNullString, vbNullString, SW_SHOW
End Sub

2005-11-24 08:00:05 補充:
VB心得筆記
http://www.hosp.ncku.edu.tw/~c
ww/html/vb.html

2005-11-23 03:32:03 · answer #1 · answered by Sean 5 · 0 0

我想到的是直接把WORD給引用進來,然後打開檔案...

2005-11-23 06:13:58 · answer #2 · answered by Anonymous · 0 0

有 Shell or ShellExecute api

2005-11-22 22:16:12 · answer #3 · answered by W.J.S. 7 · 0 0

fedest.com, questions and answers