Batch file macro

  • Thread starter gmazza via AccessMonster.com
  • Start date
G

gmazza via AccessMonster.com

Hey there,
I am running a macro through a batch file.
In my batch file I have some code, then my statement to run my macro:
"C:\Program Files\Microsoft Office\Office12\msaccess.exe" "C:\Documents and
Settings\gmazza\desktop\Promotions Tool v0h.accdb" /x PaymentRequest

then some more code.

At the end of my macro I have DoCmd.quit
Problem is, after it quits Access, it doesn't run the rest of my code in my
batch, which is just deleting some files on my drive but still, I need this
done.
Any thoughts?
 
G

gmazza via AccessMonster.com

I don't want to run my macro when Access is closed, I want to run my deletion
of files after the macro is complete as I need the files for the macro. Does
anyone know why this wouldn't work?

Gina said:
gmazza,

You would need to delete those files before qutting Access. Once Access is
closed your macro cannot run.
Hey there,
I am running a macro through a batch file.
[quoted text clipped - 12 lines]
done.
Any thoughts?
 
G

Gina Whipp

gmazza,

As stated in my reply... Once Access quits it can no longer run your macro.
Perhaps I am misunderstanding your original posting. Are you saying you
delete the files THEN quit Access? If that is what you are doing, please
provide the action you are using to delete the file.

--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

gmazza via AccessMonster.com said:
I don't want to run my macro when Access is closed, I want to run my
deletion
of files after the macro is complete as I need the files for the macro.
Does
anyone know why this wouldn't work?

Gina said:
gmazza,

You would need to delete those files before qutting Access. Once Access
is
closed your macro cannot run.
Hey there,
I am running a macro through a batch file.
[quoted text clipped - 12 lines]
done.
Any thoughts?
 
G

gmazza via AccessMonster.com

I think we are misunderstanding eachother :)
After my macro is done running, Access closes, thats perfect. So after all
that, control should go back to my batch file, where I then want to delete
the files I imported off my hard drive.
Problem is when Access quits, I look at my DOS window and it is still sitting
on the line:
"C:\Program Files\Microsoft Office\Office12\msaccess.exe" "C:\Documents and
Settings\gmazza\desktop\Promotions Tool v0h.accdb" /x PaymentRequest
and it just sits there, even though Access is closed. It should finish with
that line and then do the rest of my commands in my batch file.
HTH

Gina said:
gmazza,

As stated in my reply... Once Access quits it can no longer run your macro.
Perhaps I am misunderstanding your original posting. Are you saying you
delete the files THEN quit Access? If that is what you are doing, please
provide the action you are using to delete the file.
I don't want to run my macro when Access is closed, I want to run my
deletion
[quoted text clipped - 13 lines]
 
G

Gina Whipp

gmazza,

That line that it stops at is suppose to open another database and run a
macro? Because that line is telling Access to open said satabase and run a
macro. It might also help to see what is in the batch file. Technically,
this is not an Access problem it's your batch file.

--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

gmazza via AccessMonster.com said:
I think we are misunderstanding eachother :)
After my macro is done running, Access closes, thats perfect. So after all
that, control should go back to my batch file, where I then want to delete
the files I imported off my hard drive.
Problem is when Access quits, I look at my DOS window and it is still
sitting
on the line:
"C:\Program Files\Microsoft Office\Office12\msaccess.exe" "C:\Documents
and
Settings\gmazza\desktop\Promotions Tool v0h.accdb" /x PaymentRequest
and it just sits there, even though Access is closed. It should finish
with
that line and then do the rest of my commands in my batch file.
HTH

Gina said:
gmazza,

As stated in my reply... Once Access quits it can no longer run your
macro.
Perhaps I am misunderstanding your original posting. Are you saying you
delete the files THEN quit Access? If that is what you are doing, please
provide the action you are using to delete the file.
I don't want to run my macro when Access is closed, I want to run my
deletion
[quoted text clipped - 13 lines]
done.
Any thoughts?
 
P

Phil Smith

Hey Gmazza, I think you have it wrong...Follow me here...
Launch Batch file.
Opens, or is running in, Command window.
batch command blah
batch command blah
batch command blah
"C:\Program Files\Microsoft Office\Office12\msaccess.exe" "C:\Documents
and Settings\gmazza\desktop\Promotions Tool v0h.accdb" /x PaymentRequest

This opens a NEW Command window, (the one you are seeing) which IN TURN
loads MSSACCESS, and runs the macro.
At the point that the New command widow has been opened, the batch file
command to run Access is finished, and the original batch file continues
to run. IT DOES NOT STOP AND WAIT FOR ACCESS TO COMPLETE. So...
Delete files blah
Delete files blah
Delete files blah
end of batch file.

Your batch file has probably completed these things you want to happen
AFTER Access is finished, BEFORE ACCESS has even finished LOADING. much
less run your macros and done it's thing.

You can test this by putting "pause" just after your call to Access, and
you will see the original command window sitting there.

The solution to your problem is to split your batch file. Take
everything after your call to Access, and put it in a different batch
file. Then, as your last Access Macro command before you quit, call
that Macro to delete your files, using RunApp.
Now, that NEW command window should go away after access closes. If it
doesn't, then you ahve a different but minor problem.

Phil
 
G

gmazza via AccessMonster.com

Ok thanks Phil, I'll give that a try!!

Phil said:
Hey Gmazza, I think you have it wrong...Follow me here...
Launch Batch file.
Opens, or is running in, Command window.
batch command blah
batch command blah
batch command blah
"C:\Program Files\Microsoft Office\Office12\msaccess.exe" "C:\Documents
and Settings\gmazza\desktop\Promotions Tool v0h.accdb" /x PaymentRequest

This opens a NEW Command window, (the one you are seeing) which IN TURN
loads MSSACCESS, and runs the macro.
At the point that the New command widow has been opened, the batch file
command to run Access is finished, and the original batch file continues
to run. IT DOES NOT STOP AND WAIT FOR ACCESS TO COMPLETE. So...
Delete files blah
Delete files blah
Delete files blah
end of batch file.

Your batch file has probably completed these things you want to happen
AFTER Access is finished, BEFORE ACCESS has even finished LOADING. much
less run your macros and done it's thing.

You can test this by putting "pause" just after your call to Access, and
you will see the original command window sitting there.

The solution to your problem is to split your batch file. Take
everything after your call to Access, and put it in a different batch
file. Then, as your last Access Macro command before you quit, call
that Macro to delete your files, using RunApp.
Now, that NEW command window should go away after access closes. If it
doesn't, then you ahve a different but minor problem.

Phil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top