What is the command to convert a string into a command?
Preferably in the excel's cell. Thanks in advance.
Hi,VBA inquirer wrote:What is the command to convert a string into a command? Preferably in the excel's cell.
Code: Select all
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
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
Sub RunACommand()
Const CellContainingTheCommand = "B2"
Dim TheCommandToRun As String
Range(CellContainingTheCommand).Select
TheCommandToRun = ActiveCell.Text
ShellExecute 0&, vbNullString, TheCommandToRun, _
vbNullString, vbNullString, SW_SHOWDEFAULT
End Sub
Users browsing this forum: No registered users and 6 guests