LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dave Peterson
 
Posts: n/a
Default dos from excel vba?

Something like:

Option Explicit
Sub testme()

Dim myBatFile As String
Dim myStr As String
Dim myCommand As String

myBatFile = "C:\my documents\excel\myfile.bat"
myStr = "hello"

myCommand = Chr(34) & myBatFile & Chr(34) & " " & myStr

Shell Environ("comspec") & " /k " & myCommand, vbMaximizedFocus

End Sub

Change the /k to /c to dismiss that DOS window when it's done.



Jason wrote:

i mean, i see that you could run msdos application by using the shell, but
could you pass any parameter to the application?

"Jason" wrote:

thanks for your reply, but the thing is, i need to run a program in msdos, by
changing its current directory and running an exe file, and i was hoping to
do it from a userform in vba..

"Dave Peterson" wrote:

In general, you can use Shell to issue DOS commands--even call other programs.

But VBA has lots of stuff to work with files and folders built in.

Including
chdrive (to change drives)
chdir (to change folders)




dim OldPath as String
dim NewPath as string

OldPath = CurDir
newpath = "D:\somefolder"
chdrive newpath
chdir newpath

'do a lot of work and change back

chdrive oldpath
chdir oldpath




Jason wrote:

hi, is there any way that i could open and enter commands in ms dos
controlling from excel vba code?, like, say i wanted to change the current
directory in msdos from d: to c:, is there anyway that i could do it from
excel vba? if so, could you give me a hint..

--

Dave Peterson


--

Dave Peterson


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Stop excel from dropping the 0 in the beginning of a number? Rosewood Setting up and Configuration of Excel 12 April 4th 23 02:12 PM
Open Excel 2003 from Windows Explorer pmpjr Excel Discussion (Misc queries) 9 September 11th 06 03:58 PM
Excel Range Value issue (Excel 97 Vs Excel 2003) Keeno Excel Discussion (Misc queries) 2 June 13th 05 02:01 PM
How Do I open an excel file without Excel Viewer support CocoriteBallGiants Excel Discussion (Misc queries) 2 February 4th 05 10:50 PM
Excel 2002 and 2000 co-install. Control Which Starts ? cnuk Excel Discussion (Misc queries) 2 January 17th 05 08:07 PM


All times are GMT +1. The time now is 05:25 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"