-
I need to have my program open a txt file and disply it, but it is very very large. so I would like to have the win program word pad open it. :-)
either with in my program or externally is fine, It is just to view a couple thousand line log file.
Please help...
Sincerely,
Nick
-
Code:
'notepad:
Shell "Notepad.exe C:\txtfile.txt", vbNormalFocus
'wordpad:
Shell "Wordpad.exe C:\txtfile.txt", vbNormalFocus
-
<?>
You need the path for the application as well as the path for the file to be opened. Use shelldef as it will find the correct application with which to open the file:
Code:
Option Explicit
'put this in a bas module
'
Public Declare Function ShellEx Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As Any, _
ByVal lpDirectory As Any, ByVal nShowCmd As Long) As Long
'
Sub ShellDef(strFileName)
Dim x As Long
x = ShellEx(Form1.hwnd, "open", strFileName, "", "", 1)
End Sub
'put this in your form
'whatever is needed to open your file will open it.
Option Explicit
Private Sub Command1_Click()
Dim strYourFileVariable$
strYourFileVariable = "C:\my documents\readme.txt"
ShellDef strYourFileVariable
End Sub
-
For speed, send it straight to notepad. If it's small enough, NP will load it quickly, otherwise it will load WordPad for you and display it in that.
-
<?>
When you use shelldef, if it has a .txt extension the Notepad will be the guy if it's within the scope of the program to open it.