![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Guest
Posts: n/a
|
Can you execute a DOS command from an Excel Macro?
|
|
|
|
#2 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Quote:
can be done in VBA. What are you trying to do ?? Have a look 1st at the shell command Ivan |
|
|
|
|
|
|
#3 |
|
Guest
Posts: n/a
|
I want to run another application ie have a shortcut to it in the spreadsheet or a button with a macro assigned to it that will run the program. This is the command line as I would to run it form the DOS prompt:
"C:Program FilesTTERMPROttpmacro.exe" "C:Program FilesTTERMPROlogin.ttl" Thanks. |
|
|
|
#4 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
How about creating a batch file (*.bat) and running that using "shell"?
|
|
|
|
|
|
#5 |
|
Guest
Posts: n/a
|
Yep,
That will work. Thanks Heaps. |
|
|
|
#6 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Christchurch New Zealand
Posts: 1,030
|
using a bat file is easy enough but what if you don't want to tag a batch file along with the spreadsheet can you not write specific code e.g. c:runme.exe
|
|
|
|
|
|
#7 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
You can create a batch file using VBA though using "Open", "Write #" etc. You just create the file in a temp directory and delete it on exiting Excel to tidy up. In this case it would only take about 5 lines of code and negligible execution time.
|
|
|
|
|
|
#8 |
|
Guest
Posts: n/a
|
Thanks all for your help.
With your help I have found that I can do what I wanted as follows: ===== Sub GatherData () Dim ReturnValue ReturnValue = Shell("""C:Program FilesTTERMPROttpmacro.exe"" ""G:iDO Messagingttermpromacrosbdf.ttl""", 1) AppActivate ReturnValue End Sub ====== The trick was to get the "" right. Thanks Again! |
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|