Code: |
Shell ("start " & Chr(34) & "C:\Folder Contents.txt" & Chr(34)), vbHide |
Code: |
' API stuff for launching the file:
Private Declare Function ShellExecute Lib "shell32.dll" Alias _ "ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As _ String, ByVal lpszFile As String, ByVal lpszParams As String, _ ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long Private Declare Function GetDesktopWindow Lib "user32" () As Long Const SW_SHOWNORMAL = 1 Const SE_ERR_FNF = 2& Const SE_ERR_PNF = 3& Const SE_ERR_ACCESSDENIED = 5& Const SE_ERR_OOM = 8& Const SE_ERR_DLLNOTFOUND = 32& Const SE_ERR_SHARE = 26& Const SE_ERR_ASSOCINCOMPLETE = 27& Const SE_ERR_DDETIMEOUT = 28& Const SE_ERR_DDEFAIL = 29& Const SE_ERR_DDEBUSY = 30& Const SE_ERR_NOASSOC = 31& Const ERROR_BAD_FORMAT = 11& |
Code: |
Function StartDoc(DocName As String) As Long
Dim Scr_hDC As Long Scr_hDC = GetDesktopWindow() StartDoc = ShellExecute(Scr_hDC, "Open", DocName, _ "", "C:\", SW_SHOWNORMAL) End Function |
Code: |
r = StartDoc("C:\myFile.txt") ' Edit this line!
If r <= 32 Then 'There was an error Select Case r Case SE_ERR_FNF strMessage = "File not found" Case SE_ERR_PNF strMessage = "Path not found" Case SE_ERR_ACCESSDENIED strMessage = "Access denied" Case SE_ERR_OOM strMessage = "Out of memory" Case SE_ERR_DLLNOTFOUND strMessage = "DLL not found" Case SE_ERR_SHARE strMessage = "A sharing violation occurred" Case SE_ERR_ASSOCINCOMPLETE strMessage = "Incomplete or invalid file association" Case SE_ERR_DDETIMEOUT strMessage = "DDE Time out" Case SE_ERR_DDEFAIL strMessage = "DDE transaction failed" Case SE_ERR_DDEBUSY strMessage = "DDE busy" Case SE_ERR_NOASSOC strMessage = "No association for file extension" Case ERROR_BAD_FORMAT strMessage = "Invalid EXE file or error in EXE image" Case Else strMessage = "Unknown error" End Select MsgBox strMessage End If |
output generated using printer-friendly topic mod, All times are GMT + 2 Hours