run DOS command in excel

jjpkraft

New Member
Joined
Feb 26, 2002
Messages
32
I'm trying to run a string of DOS commands using a macro. I'm completely lost.
I can do the task in DOS but don't know how to access it using VBA code.
I've found sites that talk about doing it but can't find one that tells me how to do it.
 
Waterloo, I hear they have a great CIS school up there (my Dad went there for Physics), the home of Cobalt (and y2k issues).

Most VBA comes from DOS, e.g, Dos commands, like Dir, copy, etc... have a functional purpose in VBA. Which commands are you trying to run?

_________________
Cheers,<font size=+2><font color="red"> Nate<font color="blue">O</font></font></font>
This message was edited by NateO on 2002-05-22 07:26
 
Upvote 0
I picked up a Physics minor Waterloo 5 years ago. Small world.

We've got a telnet mail server and I'm opening it up with "telnet 111.111.1.1 11" when I'm in DOS.
Then I'm sending an email from an anonymous email...we're using this for a Q&A program.
 
Upvote 0
I picked up a Physics minor Waterloo 5 years ago. Small world.

We've got a telnet mail server and I'm opening it up with "telnet 111.111.1.1 11" when I'm in DOS.
Then I'm sending an email from an anonymous email...we're using this for a Q&A program.
 
Upvote 0
On 2002-05-22 07:17, jjpkraft wrote:
I'm trying to run a string of DOS commands using a macro. I'm completely lost.
I can do the task in DOS but don't know how to access it using VBA code.
I've found sites that talk about doing it but can't find one that tells me how to do it.

Lookup the Shell comand in the VBA help file

example of running Dos command;

<pre/>
Sub RemoveDir_WithFiles()
Shell "command.com /c RD C:mydir"
End Sub
</pre>

Note: In Microsoft Excel, when you use the Shell function in a VBA macro to execute an external MS-DOS command, you should add the /c switch after command.com.
This only applies to the Core commands DIR ,CLS,DEL ,CD,MD (MKDIR) ,RD (RMDIR),COPY

BUT you can do these in VBA without shelling

To run a Batch file just use;

<pre/>
Sub DOSB()
Dim varProc As Variant

varProc = Shell("RunMe.bat", 6)

End Sub
</pre>
 
Upvote 0
I've got the macro to open the telnet.exe file. I now need to send information from Excel to the telnet session.
I'm trying to declare the telnet application as an object. How can I do that?
 
Upvote 0
On 2002-05-22 12:24, jjpkraft wrote:
I've got the macro to open the telnet.exe file. I now need to send information from Excel to the telnet session.
I'm trying to declare the telnet application as an object. How can I do that?

I don't think the Telnet application is supported....you will have to use SendKeys

Lookup this while in the VBA Editor for help
 
Upvote 0
Hi jjpkraft,

I don't know about telnet session very much. So just information...

In case I am using another application (like as400) when need to send information,
I always use like following.

<pre>
Sub test()
Const strApName = "pcsft5.exe"
Const strInfo = "C:Program FilesPersonal CommunicationsPRIVATESelsMaster.TTO"
Dim i As Double
i = Shell(strApName & " " & strInfo, 1)
End Sub
</pre>

HTH
 
Upvote 0

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