PDA

View Full Version : Solved: Viewing a text file from within Excel



pcollins
11-01-2007, 03:26 PM
Can you start another program inside of an excel macro? I would like to have notepad open a particular file to be viewed after my excel macro does the conversion to a csv file if possible.

tpoynton
11-01-2007, 04:53 PM
I've never done it, but a google search for 'vba shell' revealed http://www.mvps.org/dmcritchie/excel/shell.htm , which should get you started.

lucas
11-01-2007, 07:58 PM
From the kb...Joseph's follow hyperlink method.....click here (http://vbaexpress.com/kb/getarticle.php?kb_id=905)

DHS100
11-02-2007, 03:03 AM
Something like this migh work...

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
Const SW_HIDE = 0
Const SW_SHOWNORMAL = 1
Const SW_NORMAL = 1
Const SW_SHOWMINIMIZED = 2
Const SW_SHOWMAXIMIZED = 3
Const SW_MAXIMIZE = 3
Const SW_SHOWNOACTIVATE = 4
Const SW_SHOW = 5
Const SW_MINIMIZE = 6
Const SW_SHOWMINNOACTIVE = 7
Const SW_SHOWNA = 8
Const SW_RESTORE = 9
Const SW_SHOWDEFAULT = 10
Const SW_MAX = 10
Private Sub cmdExcel_Click()
ShellExecute 0&, vbNullString, "notepad", "C:\Test.txt", "C:\WINDOWS\system32\notepad.exe", SW_SHOWDEFAULT
End Sub