Open/Run Another Application/File Using VBA

animas

Active Member
Joined
Sep 28, 2009
Messages
396
I need to open/launch
-applications like Outlook, IE
-files like .bat, .xls,
-folders (with windows explorer)

using VBA.

How to code this?
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
You can use Shell:
Code:
Shell "Notepad.exe", vbnormalfocus
for example.
 
Upvote 0
Code:
Shell "Outlook.exe", vbNormalFocus
worked.

Code:
Shell "emule.exe", vbNormalFocus
didn't work.

is shell command for microsoft's programs only?
 
Upvote 0
No, but you need to specify the full path if the path is not included in your system's PATH environment variable. Generally it's safer to include the full path anyway.
 
Upvote 0
now i need to take the program names from range B2:B100 of Sheet1. the list will increase or decrease within the range.

Prevoius code
Code:
Sub OpenApplications()

    Shell "Notepad.exe", vbNormalFocus    
    Shell "Outlook.exe", vbNormalFocus    
    Shell "D:\Program Files\eMule\emule.exe", vbNormalFocus

End Sub
what should be the new code?

Sample Data


<table style="padding-right: 2pt; padding-left: 2pt; font-size: 11pt; font-family: Calibri,Arial; background-color: rgb(255, 255, 255);" border="1" cellpadding="0" cellspacing="0"> <colgroup> <col style="font-weight: bold; width: 30px;"> <col style="width: 64px;"> <col style="width: 234px;"></colgroup> <tbody> <tr style="font-weight: bold; font-size: 8pt; background-color: rgb(202, 202, 202); text-align: center;"> <td>
</td> <td>A</td> <td>B</td></tr> <tr style="height: 18px;"> <td style="font-size: 8pt; background-color: rgb(202, 202, 202); text-align: center;">1</td> <td>
</td> <td style="font-weight: bold; background-color: rgb(192, 192, 192);">Programs</td></tr> <tr style="height: 18px;"> <td style="font-size: 8pt; background-color: rgb(202, 202, 202); text-align: center;">2</td> <td>
</td> <td>Notepad.exe</td></tr> <tr style="height: 18px;"> <td style="font-size: 8pt; background-color: rgb(202, 202, 202); text-align: center;">3</td> <td>
</td> <td>Outlook.exe</td></tr> <tr style="height: 18px;"> <td style="font-size: 8pt; background-color: rgb(202, 202, 202); text-align: center;">4</td> <td>
</td> <td>D:\Program Files\eMule\emule.exe</td></tr> <tr style="height: 18px;"> <td style="font-size: 8pt; background-color: rgb(202, 202, 202); text-align: center;">5</td> <td>
</td> <td>
</td></tr> <tr style="height: 18px;"> <td style="font-size: 8pt; background-color: rgb(202, 202, 202); text-align: center;">6</td> <td>
</td> <td>
</td></tr> <tr style="height: 18px;"> <td style="font-size: 8pt; background-color: rgb(202, 202, 202); text-align: center;">7</td> <td>
</td> <td>
</td></tr> <tr style="height: 18px;"> <td style="font-size: 8pt; background-color: rgb(202, 202, 202); text-align: center;">8</td> <td>
</td> <td>
</td></tr> <tr style="height: 18px;"> <td style="font-size: 8pt; background-color: rgb(202, 202, 202); text-align: center;">9</td> <td>
</td> <td>
</td></tr> <tr style="height: 18px;"> <td style="font-size: 8pt; background-color: rgb(202, 202, 202); text-align: center;">10</td> <td>
</td> <td>
</td></tr> <tr style="height: 18px;"> <td style="font-size: 8pt; background-color: rgb(202, 202, 202); text-align: center;">11</td> <td>
</td> <td>
</td></tr> <tr style="height: 18px;"> <td style="font-size: 8pt; background-color: rgb(202, 202, 202); text-align: center;">12</td> <td>
</td> <td>
</td></tr></tbody></table>
 
Last edited:
Upvote 0
Hi

If you select a non-empty cell in column B, and add this code to a button, it can work:

Code:
Sub OpenApplication()
    Shell ActiveCell.Text, vbNormalFocus
End Sub

But I agree with Norie...

Wigi
 
Upvote 0
i was expecting some loop codes that will loop through the list in range B2:B100 and open all those programs in list. a checking if the programs are already open will be great.

every day i need to open many progams, folders and files at office start. so do my collegues. i could easily use the existing backend code. but my colleagues can't. for their ease of use i need to put the list in excel column.
 
Upvote 0

Forum statistics

Threads
1,223,629
Messages
6,173,440
Members
452,515
Latest member
marinacalus

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top