|
-
Feb 2nd, 2005, 09:20 AM
#1
Thread Starter
Frenzied Member
Open Text File In Notepad {RESOLVED}
My application generates a number of .Log files. All are standard text files that I can easily view in Notepad. What I'd like to do is add a menu item which, from within my program, my user to open them and view them, in notepad. I've tried:
VB Code:
Shell "c:\myfolder\mylog.log", vbNormalFocus
'and I have tried
Shell "notepad.exe c:\myfolder\mylog.log", vbNormalFocus
And neither one works. What am I doing wrong?
Last edited by SeanK; Feb 2nd, 2005 at 09:51 AM.
Beantown Boy
Please use [highlight=vb]your code goes in here[/highlight] tags when posting code.
When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
-
Feb 2nd, 2005, 09:30 AM
#2
-
Feb 2nd, 2005, 09:41 AM
#3
Thread Starter
Frenzied Member
Re: Open Text File In Notepad
Here is exactly what I have:
VB Code:
Private Sub mnuViewLog_Click()
Shell "notepad C:\AllState\LogFiles\Wednesday\ProcessLog_050202082323.log", vbNormalFocus
End Sub
And nothing happens. No errors. No log file. Are my file names and/or folder names too long?
Beantown Boy
Please use [highlight=vb]your code goes in here[/highlight] tags when posting code.
When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
-
Feb 2nd, 2005, 09:42 AM
#4
Junior Member
Re: Open Text File In Notepad
Specify the full path (you might need the GetWindowsDirectory API function):
VB Code:
Shell "c:\windows\notepad.exe C:\SCANDISK.LOG", vbNormalFocus
Note that the Shell function is not the same as Start Menu/Run program.
Last edited by _joepsy_; Feb 2nd, 2005 at 09:46 AM.
-
Feb 2nd, 2005, 09:50 AM
#5
Thread Starter
Frenzied Member
Re: Open Text File In Notepad
Now I remember why I HATE useing Shell. I fixed it by tossing Shell out the nearest window and using the ShellExecute API. That never fails and I don't have to worry where Notepad is on anyone's PC! If anyone is interested:
VB Code:
Option Explicit
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
Private Const SW_NORMAL = 1
Private Sub mnuViewLog_Click()
On Error Resume Next
ShellExecute Me.hwnd, vbNullString, "C:\AllState\LogFiles\Wednesday\ProcessLog_050202082323.log", vbNullString, "C:\", SW_SHOWNORMAL
End Sub
Beantown Boy
Please use [highlight=vb]your code goes in here[/highlight] tags when posting code.
When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|