MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Apr 30th, 2002, 05:23 AM   #1
grovithis
New Member
 
Join Date: Apr 2002
Location: athens
Posts: 15
Default

I have a sub call run_bat wich works great
unfortunatly the next sub routine nust wait until the bat file is run and then only start HOW!!!!!
NO idea even what the command should be
grovithis is offline   Reply With Quote
Old Apr 30th, 2002, 05:45 AM   #2
Robb__
New Member
 
Join Date: Apr 2002
Posts: 41
Default

grovithis

Try: DoEvents

It hands over to the operating system. Since I do not know your code, just look it up in Help for the best way to use it.

Any help?

Regards

Robb__
Robb__ is offline   Reply With Quote
Old Apr 30th, 2002, 06:02 AM   #3
grovithis
New Member
 
Join Date: Apr 2002
Location: athens
Posts: 15
Default

looking it up but here is what it looks like

Sub Automatic()
Call Copydata
Call Run_bat
Call Copydata2
Call Clearsheets
Call makeheadings
Call MakeSales
Call Hidecol

End Sub
'********************************************

Sub Copydata()

Windows("Φορτώσεις από Αποθήκες 10ημέρου.xls").Activate
Sheets("data").Select
Range("A1:BW500").Select
Selection.ClearContents
Sheets("pgm").Select
Range("A1").Select

a whole bunch of stuff
Windows("Φορτώσεις από Αποθήκες 10ημέρου.xls").Activate
Sheets("pgm").Activate
Range("A1").Select

End Sub

Sub Run_bat()

Shell "o:as400test.bat"

End Sub


Sub Copydata2()

Windows("Φορτώσεις από Αποθήκες 10ημέρου.xls").Activate
Sheets("data2").Select
Range("A1:AZ1000").Select
a whole bunch of stuff
grovithis is offline   Reply With Quote
Old Apr 30th, 2002, 06:19 AM   #4
Robb__
New Member
 
Join Date: Apr 2002
Posts: 41
Default

Do you want the bat file routine to finish before the next routine starts, or are you wanting the routines to run together?

Regards

Robb__
Robb__ is offline   Reply With Quote
Old Apr 30th, 2002, 06:24 AM   #5
grovithis
New Member
 
Join Date: Apr 2002
Location: athens
Posts: 15
Default

I want the bat routine to finish and then only must the next routine start
grovithis is offline   Reply With Quote
Old Apr 30th, 2002, 06:35 AM   #6
Robb__
New Member
 
Join Date: Apr 2002
Posts: 41
Default

I see - tricky because Shell function has a habit of doing that.

Try inserting DoEvents in the calling routine:

Sub Automatic()
Call Copydata
Call Run_bat
DoEvents
Call Copydata2
Call Clearsheets
Call makeheadings
Call MakeSales
Call Hidecol

End Sub

Any help?

Regards

Robb__
Robb__ is offline   Reply With Quote
Old Apr 30th, 2002, 06:43 AM   #7
grovithis
New Member
 
Join Date: Apr 2002
Location: athens
Posts: 15
Default

unfortunatly not
but hey i still have some time before i have to show them to the boss so i carry on looking
shouldnt i add an end eventline somwhere ?????

Somwhere out there as the song goes
"mmm this and closing of the month seems to be frying the brain"
grovithis is offline   Reply With Quote
Old Apr 30th, 2002, 07:43 AM   #8
robfritts
New Member
 
Join Date: Apr 2002
Location: KC, MO
Posts: 18
Default

Hey guys, I'm new here, so my solutions might be rather mundane and not very correct according to the way things are supposed to be programmed.

That in mind, what about a kick-out to the user to tell Excel *when* the bat file is complete.

The bat files I call on a regular basis still pop up windows that they execute in that the user can view, or at least see running or finished in the window name on the start-bar (win9x,winNT,etc).

Why don't you insert a MsgBox between your call to the bat and the next instruction:

'call your batch file
MsgBox("Click OK when the .bat file is complete.")
'call your next routine/whatever...

easy enough, so long as you don't mind the user being able to screw it all up for you

robfritts is offline   Reply With Quote
Old Apr 30th, 2002, 11:05 PM   #9
grovithis
New Member
 
Join Date: Apr 2002
Location: athens
Posts: 15
Default

Thanks for the help rob

We are unfortunatly talking about a user who is going to retire in about 2 years!!!!
i just changed her green moniter ( as400 )to a pc she cant use a mouse and ..........
You know the rest so have to automate everything or do it myself !!!! I love network upgrades

PS AS400 Really kicks as as a system but it does not handle graphics at all
grovithis is offline   Reply With Quote
Old May 1st, 2002, 01:08 AM   #10
Colo
MrExcel MVP
 
Colo's Avatar
 
Join Date: Mar 2002
Location: Kobe, Japan
Posts: 1,420
Default

Hi grovithis, I'm AS400 user too. Please try this.

'--Please copy this into a standard module -----------------------------------
Public Declare Function OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long
Public Declare Function WaitForSingleObject Lib "kernel32" _
(ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Public Const SYNCHRONIZE = &H100000
Public Const INFINITE = &HFFFF

Sub Automatic()
Call Copydata
Call Run_bat
Call Copydata2
Call Clearsheets
Call makeheadings
Call MakeSales
Call Hidecol
End Sub

Sub Run_bat()
Dim lngRtn As Long
Dim lngProID As Long
Dim lngProHn As Long
'Please modify the path (I can not input here "/")
lngProID = Shell("o:as400test.bat")
lngProHn = OpenProcess(SYNCHRONIZE, True, lngProID)
lngRtn = WaitForSingleObject(lngProHn, INFINITE)
lngRtn = CloseHandle(lngProHn)
End Sub
'-------------------------------------------------------------------------------

__________________
Regards,

Masaru Kaji aka Colo - Ex Microsoft MVP Since 2004 -2009
Colo is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 12:38 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes