Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I need to be able to run a dos batch file as soon as I save and exit a
spreadsheet/workbook. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
just writ down a line of code similar to following example:
Private Sub Workbook_BeforeClose(Cancel As Boolean) .. .. Call Shell("C:\file.bat", 1) .. .. end sub |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() My .bat is executed, but each command line is viewed very quickly and none of the command lines are executed. HELP. Chuckles123 -- Chuckles123 ------------------------------------------------------------------------ Chuckles123's Profile: http://www.excelforum.com/member.php...o&userid=14948 View this thread: http://www.excelforum.com/showthread...hreadid=384310 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Are you sure your batch file hasn't been executed -- Nori ----------------------------------------------------------------------- Norie's Profile: http://www.excelforum.com/member.php...fo&userid=1936 View this thread: http://www.excelforum.com/showthread.php?threadid=38431 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You can keep that command window around by using something like:
Option Explicit Sub testme() Dim myBatFileName As String myBatFileName = "C:\my file.bat" Shell Environ("comspec") & " /k " & Chr(34) & myBatFileName & Chr(34), _ vbMaximizedFocus End Sub Change the /k to /c to dismiss that DOS window when it's done. And fiddle with the vbMaximizedFocus to make it what you want. (See VBA's help for Shell to see all the options.) Chuckles123 wrote: My .bat is executed, but each command line is viewed very quickly and none of the command lines are executed. HELP. Chuckles123 -- Chuckles123 ------------------------------------------------------------------------ Chuckles123's Profile: http://www.excelforum.com/member.php...o&userid=14948 View this thread: http://www.excelforum.com/showthread...hreadid=384310 -- Dave Peterson |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() I, with your help, am getting closer. First, we are running W XP Pro, XCL 2002, M VB 6.3 on a network. This application is an utility to determine if a W Scheduled Task ha already been completed on any given day. At the time that the Shel Function is executed, there are no Workbooks open. My DOS batch fil is in a folder on our G: Drive; it contains about 25 command lines tha refer to various other files stored on the same drive. I inserted the code you recommended and ran the macro; also, I inserte a 'PAUSE' at the end of my DOS batch file. The macro finds the correc batch file, but the command prompt is 'C:\Documents an Settings\myusername\My Documents'. I would prefer not to move my DOS batch file (the G: Drive is a networ shared drive) and I also prefer not to change the path references in th batch file. Is there a way to modify my macro to accommodate my situation? Thanks for a response. Chuckles12 -- Chuckles12 ----------------------------------------------------------------------- Chuckles123's Profile: http://www.excelforum.com/member.php...fo&userid=1494 View this thread: http://www.excelforum.com/showthread.php?threadid=38431 |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Does that mean you want to change the drive and path?
If yes, then I'd include that in the .bat file: rem If you want turn off the screenupdating @echo off G: cd "G:\what ever\folder\you need" rem rest of your .bat file after this... ====== But if you fully qualify your file names (include both the drive and folder), then it shouldn't matter what the active drive and current folder is. But it is sometimes easier to just change the drive and folder. Chuckles123 wrote: I, with your help, am getting closer. First, we are running W XP Pro, XCL 2002, M VB 6.3 on a network. This application is an utility to determine if a W Scheduled Task has already been completed on any given day. At the time that the Shell Function is executed, there are no Workbooks open. My DOS batch file is in a folder on our G: Drive; it contains about 25 command lines that refer to various other files stored on the same drive. I inserted the code you recommended and ran the macro; also, I inserted a 'PAUSE' at the end of my DOS batch file. The macro finds the correct batch file, but the command prompt is 'C:\Documents and Settings\myusername\My Documents'. I would prefer not to move my DOS batch file (the G: Drive is a network shared drive) and I also prefer not to change the path references in the batch file. Is there a way to modify my macro to accommodate my situation? Thanks for a response. Chuckles123 -- Chuckles123 ------------------------------------------------------------------------ Chuckles123's Profile: http://www.excelforum.com/member.php...o&userid=14948 View this thread: http://www.excelforum.com/showthread...hreadid=384310 -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I set up a file to automatically save on exit? | Excel Discussion (Misc queries) | |||
excel save file upon exit | Excel Discussion (Misc queries) | |||
save prompt for user exit, but no save prompt for batch import? | Excel Discussion (Misc queries) | |||
How can I batch open a txt file in excel 2003 and save back as a . | Excel Discussion (Misc queries) | |||
Batch Open and Save | Excel Programming |