PDA

View Full Version : Solved: Open a "variable.exe"



Rejje
11-19-2010, 04:15 PM
Hello!

Depending on different variables I'd like for below code (or something similar) to open a variable "C:\a\b\c\program.exe" which is found a cell named "Run_this_program" in the workbook. The acrobat.exe search path is just an example. "Run_this_program" might just as well say "C:\Program Files\Microsoft Office\Office12\WINWORD.EXE".



Sub Run_exe()
Dim RetVal

RetVal = Shell("C:\Program Files\Adobe\Acrobat 8.0\Acrobat\Acrobat.EXE", 1)

End Sub


Any ideas :think: ?

Simon Lloyd
11-19-2010, 05:07 PM
Try this:

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
Sub Launch_It()
ShellExecute 0, vbNullString, Range(run_this_program), vbNullString, "C:\", 1
End Sub

slamet Harto
11-20-2010, 08:41 AM
i think you have to replace Range(run_this_program) to "acrobat.exe"

Bob Phillips
11-20-2010, 12:38 PM
Try this:

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
Sub Launch_It()
ShellExecute 0, vbNullString, Range(run_this_program), vbNullString, "C:\", 1
End Sub


The range name, run_this_program, should be in quotes.

Simon Lloyd
11-20-2010, 02:45 PM
The range name, run_this_program, should be in quotes.Thanks Bob, a mere typo whilst at work :) (i guess i'm not that great at multitasking)