Hi
If you mean VBS (as it is the VBS newsgroup)
then try...
MyPath = "E:\Tom\mytextfile.txt"
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run ("""" & myPath & """")
Do Until WshShell.AppActivate("Musicmatch.doc")
Wscript.sleep 100
Loop
set WshShell = nothing
wscript.quit
Otherwise if you mean Visual Basic (you should be in their newsgroup)
then try putting this in a module...
Private Declare Function GetDesktopWindow Lib "user32" () As Long
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
Public Sub RunShellExecute(sTopic As String, sFile As Variant, _
sParams As Variant, sDirectory As Variant, _
nShowCmd As Long)
Dim hWndDesk As Long
Dim success As Long
Const SE_ERR_NOASSOC = &H31
'the desktop will be the default for error messages
hWndDesk = GetDesktopWindow()
success = ShellExecute(hWndDesk, sTopic, sFile, sParams, sDirectory,
nShowCmd)
End Sub
Then put this in the event you want to open the document from
MyPath = "E:\Tom\mytextfile.txt"
Call RunShellExecute("open", MyPath, 0&, 0&, 10)
--
Tom
-------------------------------------
http://engines2go.com - Fast access to all the major search engines.
No Ads, Pictures or Banners.
Quote:
> How can I open a *.txt file from within a vb program?
> I can use the shell command to opne notepad but how do I start notepad
with
> a specific file???