MacRena
asked on
VBA code to open a Text file from mapped drive
hello experts,
what is the VBA code to open a Text file from a mapped drive?
i am recording receipt Numbers that the user looks at in a flat text file, and i want to have a button on the form that will open that file up in Notepad if the user needs to look at her history.
in otherwords, if the user clicks the button, i want my code to execute Notepad.exe and open up the .txt file on the user's workstation.
thanks,
mac
what is the VBA code to open a Text file from a mapped drive?
i am recording receipt Numbers that the user looks at in a flat text file, and i want to have a button on the form that will open that file up in Notepad if the user needs to look at her history.
in otherwords, if the user clicks the button, i want my code to execute Notepad.exe and open up the .txt file on the user's workstation.
thanks,
mac
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks, Jim. that was exactly what i was needing.
thanks to you also, shanesuebsahakarn., but i'm going w/ the lesser coding.
mac
thanks to you also, shanesuebsahakarn., but i'm going w/ the lesser coding.
mac
This works for me. We use the H drive as our personal storage space on our net.
I created a small file(TextDoc.txt) and tried calling it.
Dim stAppName As String
stAppName = "C:\Windows\System32\Notep ad.EXE H:\TextDoc.txt"
Call Shell(stAppName, 1)
I created a small file(TextDoc.txt) and tried calling it.
Dim stAppName As String
stAppName = "C:\Windows\System32\Notep
Call Shell(stAppName, 1)
First paste this into a new module:
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
Now call it with:
ShellExecute hwnd,"open",strFile,Chr$(0