Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / April 2005

Tip: Looking for answers? Try searching our database.

Executing shell commands in VBA

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Abhishek - 04 Apr 2005 08:31 GMT
Hi,
    Does anybody know how to execute shell commands such as "copy" in VBA.

Thanks,
Abhishek.
Vince - 04 Apr 2005 09:17 GMT
Simplest method is:

Dim a As String
a = "c:\windows\system32\xcopy c:\wf.exe c:\aa.exe "
Shell (a)

> Hi,
>      Does anybody know how to execute shell commands such as "copy" in VBA.
>
> Thanks,
> Abhishek.
Vince - 04 Apr 2005 09:19 GMT
BTW, FWIW, I would rather use the filesystemobject to do file manipulation
like copying, deleting and renaming files than shell system commands.

> Hi,
>      Does anybody know how to execute shell commands such as "copy" in VBA.
>
> Thanks,
> Abhishek.
Michael Bednarek - 04 Apr 2005 14:40 GMT
On Mon, 4 Apr 2005 13:06:56 +0530, "Abhishek"
<abhi_narulkar@rediffmail.com> wrote in
microsoft.public.word.vba.general:

>     Does anybody know how to execute shell commands such as "copy" in VBA.

By invoking your shell with the appropriate arguments.

Assuming that it's the command COPY of CMD.EXE you desire to execute,
the command might look like:
 Shell ("cmd /c copy source.dat target.dat")
For details see CMD /? from a CMD prompt.

However, as Vince suggested, methods native to VBA are probably
preferrable.

Signature

Michael Bednarek   http://mbednarek.com/   "POST NO BILLS"

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.