How to open *.txt file 
Author Message
 How to open *.txt file

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???


Tue, 13 May 2003 18:45:48 GMT  
 How to open *.txt file
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???



Tue, 13 May 2003 13:30:08 GMT  
 How to open *.txt file
woops...
the VBS version should be...

MyPath = "E:\Tom\mytextfile.txt"
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run ("""" & myPath & """")
Do Until WshShell.AppActivate( MyPath )
  Wscript.sleep 100
Loop
set WshShell = nothing
wscript.quit

--
Tom           [Thanks Tom ;-)   yes you]
-------------------------------------
http://engines2go.com - Fast access to all the major search engines.
No Ads, Pictures or Banners.


Quote:
> 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.



> > 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???



Tue, 13 May 2003 13:34:15 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Question: Opening .txt file with vba

2. Newbie Here...Need Simple Code to Open txt file

3. Help in opening TXT files

4. Merging multiple .txt files into one .txt file

5. Adding .TXT files to a VB program without the .TXT file

6. opening a .txt file in ASP

7. Open txt file in excel and have data in seperate columns

8. Open .txt file in Word and manipulate automatically

9. Open a txt files

10. open txt file and read strings

11. Opening .txt file in BASIC

12. open a txt file for the user to view and read

 

 
Powered by phpBB® Forum Software