PDA

View Full Version : Excel "Application.Wait", Access Equivelent?



andysuth
08-06-2008, 08:19 AM
Hi,

I'm trying to transfer a macro from Excel to Access (that is, I'm trying to re-write a macro I have written in Excel to make it function in Access, not write a macro to import data from excel to access).

It's all gone pretty well so far, but I'm stuck on two critical lines, were the macro pretends to be a user typing into another application (simple lines like "Update" and "Print" and "Save As") in the form of <CTRL><L> <CTRL><P> etc.

It works fine in Excel, with this code (sample only, not whole sequence!)


Application.Wait Now() + TimeSerial(0, 0, 12)
Application.SendKeys "^l", True



But Access doesn't like the application.wait or application.sendkeys methods(?).

This is a critical part of the operation, and it interfaces with software that does not distribute an API.

Can someone tell me how to "Sendkey" and "wait" in Access?

Thanks,

-Andy.

CreganTur
08-06-2008, 08:27 AM
Well... this is just a guess, but you might be able to get this to work in Access by setting a reference to Miscrosoft Excel xx.0 Object Library (where xx.0 is whatever version number you have on your machine).

Setting this reference makes all of Excel's objects and methods available to Access... so it might open up Application.Wait and Application.SendKeys for use.

andysuth
08-06-2008, 08:37 AM
addendum:

I've got the "Sendkeys" part working, apparently I just take the "Application." away from the line.

It's just the "application.wait" that doesn't work.



SendKeys "^l", True



Any clues with the wait or pause command on the Access VBA?

Thanks,

-Andy.

CreganTur
08-06-2008, 08:52 AM
Here's a kb article (http://vbaexpress.com/kb/getarticle.php?kb_id=626) that provides an alternate way of delaying a script.

andysuth
08-06-2008, 09:03 AM
Thanks,

I may use that. With hindsight I think I originally used a delay routine like that before I discovered the "Application.wait".

It just seemed neater.

I used DoLoops (or equivelent, probably "btfsc" with a "goto") back in the day on a PIC I had controlling stepper motor speeds.

-Andy.