Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help WRT: Run Access Macro from Windows XP Scheduler

Status
Not open for further replies.

frstwrldprblm

Programmer
Sep 8, 2009
12
US
thank you for the very helpful post found here:

my .bat file is below

"C:\Program Files\Microsoft Office\Office11\msaccess.exe" "C:\Documents and Settings\Administrator\Desktop\simplestaticsimple.mdb" /x Data

i see the command line pop up for a fractional second, and then goes away. i tried running the routine on its own (works perfectly) yet my .bat does not work.

any help would be tremendous.
 
i tried running the routine on its own (works perfectly)
Do you mean you ran the exact line you posted from the command line and it worked or you ran your macro and it worked?

Regards

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before post
 
Quote:
i tried running the routine on its own (works perfectly)
Do you mean you ran the exact line you posted from the command line and it worked or you ran your macro and it worked?
Regards
HarleyQuinn

harley,
i mean that i ran my vba coding within access, and it executes my desired task correctly (some ground up debugging), yet when I attempt to run the .bat code, it is unsuccessful at running the macro (access does not open, there is no action aside from the command line opening for a fractional second as noted).

thank you, and sorry for not being more specific.
 
Sometimes in .bat files, you need to double-double-quote, especially when there's a space in the path or filename, ie

""C:\Program Files\Microsoft Office\Office11\msaccess.exe""
--Jim
 
No worries [smile]

I'd hazard a guess that it's a problem finding your msaccess.exe.

Open up command prompt (Start-->Run type cmd and click OK) then paste your line from the .bat file in there (right click and paste as Ctrl+V won't work unfotunately) and hit return. This will allow you to see any errors that occur within the command prompt (as it will stay open).

See what it says and come back to us.

Hope this helps

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before post
 
jsteph (TechnicalUser)
8 Sep 09 11:32
Sometimes in .bat files, you need to double-double-quote, especially when there's a space in the path or filename, ie

""C:\Program Files\Microsoft Office\Office11\msaccess.exe""
--Jim

no luck on this.
 
No worries

I'd hazard a guess that it's a problem finding your msaccess.exe.

Open up command prompt (Start-->Run type cmd and click OK) then paste your line from the .bat file in there (right click and paste as Ctrl+V won't work unfotunately) and hit return. This will allow you to see any errors that occur within the command prompt (as it will stay open).

See what it says and come back to us.

Hope this helps

okay, silly error, i did not check that. my location was office10, now 11. that is solved.

yet still,
i am being told that my macro is not being found.

Modules: Module1
Macro Name: Data
 
The /x switch is used to run macros, I don't think it can be used this way to run subs/functions.

Regards

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before post
 
sorry for the dense response, but are they not the same thing?
 
I've dropped a bit of a clanger here I'm afraid [blush]

I forgot that if you create a macro (Insert-->Macro) with the RunCode action, in the Function Name box type in the name of your function (or if Data is a sub then the name of a Function that calls Data) and save your new macro. Then use this name in the bat file (rather than Data) and it should work fine.

Hope this helps

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before post
 
so something along the lines of:

function A()
runcode data
end function

?
 
Or simply create a new module (Insert-->Module) and paste in the following:
Code:
Function A()
Data
End Function
Then use the information I posted in my last post to create a macro and all should be well.

Hope this helps

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before post
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top