473,396 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Trying to get Excel Macro to pause will .bat file runs

63
I am trying to get an excel macro to pause while a .bat file runs. Here is my code so far:

Call Shell("Q:\IT\Quantum\XXXX.bat", vbNormalFocus)

Workbooks.Open Filename:="C:\Filename.xls"


The XXXX.bat file generates the Filename.xls file - so I need the macro to pause until the .bat file has finished running.

Any ideas?!!

thanks
May 9 '08 #1
2 2663
QVeen72
1,445 Expert 1GB
Hi,

After Shell, Sleep for few seconds, do events..

Expand|Select|Wrap|Line Numbers
  1. 'Declare This API in Form Level 
  2. Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
  3.  
  4.  
  5. Call Shell("Q:\IT\Quantum\XXXX.bat", vbNormalFocus)
  6. Sleep 10000   'Sleep for 10 seconds
  7. DoEvents
  8. DoEvents
  9. Workbooks.Open Filename:="C:\Filename.xls"
  10.  
REgards
Veena
May 9 '08 #2
grego9
63
Thanks Veena - but I need the macro to wait until the file has actually be saved down (the one that is generated from the XXXX.bat process) - this can take 5 minutes or it could take 3 minutes - so rather than a pause I guess I need a wait command.

I tried the command you added - but I am not too hot on the 'declare' stuff. How do I enter this API in form level

apologies for the stupid questions!







'Declare This API in Form Level
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)


Call Shell("Q:\IT\Quantum\XXXX.bat", vbNormalFocus)
Sleep 10000 'Sleep for 10 seconds
DoEvents
DoEvents
Workbooks.Open Filename:="C:\Filename.xls"
[/code]

REgards
Veena[/quote]
May 9 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Lize | last post by:
Hi, I'm writing an ASP application to open an excel workbook, then run a macro stored in the excel file, which produces outputs that will be displayed back onto my ASP application. Now the...
2
by: Mrs Howl | last post by:
I don't know if there's even a way to do what I want. I click on a button in an Access form, and it opens an instance of Excel, and opens a workbook and runs a macro that's in it. So far, fine,...
1
by: Steven Stewart | last post by:
I have a user who has been using Excel for a while to keep statistics and print reports. She finds using it cumbersome because of long formulas and a lot of copying and pasting. I have designed...
1
by: Giganews | last post by:
I have an Access 97 database in which I am running an Excel macro through automation. The macro in Excel is as follows: Worksheets("Sheet1").Protect Password:="****", DrawingObjects:=True,...
2
by: geronimo_me | last post by:
Hi, I have the following code in an access module: Sub Run_Excel_Macro() Dim xls, xlWB As Object Dim strFile, strMacro As String
5
by: snicks | last post by:
I'm trying to exec a program external to my ASP.NET app using the following code. The external app is a VB.NET application. Dim sPPTOut As String sPPTOut = MDEPDirStr + sID + ".ppt" Dim p As...
7
by: Holger Fitschen | last post by:
Hi to all, I want to use the Excel solver in a VB.Net project. The macro Sub Makro1Solver() Application.Run "Solver.xla!Auto_Open" SolverReset Worksheets(1).Select...
6
by: Annalyzer | last post by:
My database must produces a .csv file with a header line that is different from the detail lines. This .csv file contains a monthly report to an outside agency and is uploaded online so it must...
1
by: Catbkr1 | last post by:
I have to automatically create some Excel Spreadsheets based on automatically generated .CSV files that are produced overnight. Each .CSV has several columns that need to be deleted. The same...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.