RE: Sendkeys in Office 2003



The "True" and "False" flag may work differently in Access 2003. The fale is
supposed to wait and seems to execute the command at the typographic rate set
in control pannel.

Often you will send the keys before the menu or Widnows screen is ready to
take the keystrokes. In that case the keys are sent and you get nothing.
Sometimes the first few keystrokes are lost in a transmission.

I uses several techniques to defeat the timeing of a macro.



I use the "{home}" key as a nonsense time waster. For example,

SendKeys "{home 100}Then your important commands", true

Then if 1 to 99 of the {home} keystrokes is truncated you still get your
critical data.

Here is where the true and false swith comes into play, I think, 100
keystrokes under true thaks about a second. 100 keystorkes under false may
take 3-10 seconds.

I will set up a useless loop in visual basic to wast some time and let a
window open or a dialog box to appear.

Dim Wwait

For Wwait = 1 to 1000000
next WWait

If you want to waste some time in a loop like this at 1 gig your loop needs
to be big.

I also use the timer interval to send code at specific times when my target
applicaiton is very sluggish.

This is all sloppy coding and what I call brute force to accomplish your
goals. But it can be the difference between getting the job done or not.

I order to be certian I often must use both in the same macro.

You may have better luck with the domnu commands. Often you have very good
direct commands to accomplish your goal. SendKeys are my last resort usually
when controlling legacy applicaitons by Access.

DoCmd.RunCommand acCmdSelectAll
DoCmd.RunCommand acCmdRecordsGoToFirst
DoCmd.RunCommand acCmdCopy
DoCmd.RunCommand acCmdPaste
DoCmd.RunCommand acCmdPasteAppend
DoCmd.RunCommand acCmdFind
DoCmd.RunSQL "DELETE ZF18.Document_Date FROM ZF18 WHERE
(((ZF18.Document_Date) Is Not Null));"
DoCmd.RunCommand acCmdRecordsGoToNew
DoCmd.Maximize
DoCmd.DeleteObject acTable, "ZF18"
DoCmd.Close acForm, "Menu", acSaveYes
DoCmd.OpenForm "Menu"

Some examples that are very usefull.

Direct commands are always better than SendKeys
examples when working from within Access. They do not present timing
issues, they don't run out of order, and they give a much more depenable
result.




"B.S.R." wrote:

> We recently upgraded from Office 97 to Office 2003 and have noticed that our
> SendKeys function no longer works. We use it when programmatically printing
> a report to Adobe PDF; we loop through a variable (e.g. "Department") and
> print the report once for each department. We use the SendKeys function to
> pass along the name and directory location of the file to be saved, as well
> as to hit "Enter".
>
> Do any of you know of how SendKeys may have changed in Office 2003? I've
> been trying to debug it and I know that the keys are being sent, it's just
> that the timing is off. I've tried putting the Sendkeys both before and
> after the code that prints the report.
>
> Thanks in advance for your advice!
>
.



Relevant Pages

  • Re: Programmatically insert Visio pictures
    ... Re the cells I would just copy and the formulae from an existing image shape ... By using the no wait option on the sendkeys you get it to ... without waiting for the keys to be processed. ... This works perfectly in VBA in a Visio macro. ...
    (microsoft.public.visio.developer)
  • Re: Word Macro, Recording Stops in Eqn Editor
    ... Thanks for your idea but I could not get the SendKeys ... keystrokes passed to MathType. ... I could not get MathType ... >Bear in mind that Word (ie your macro) gets no message ...
    (microsoft.public.word.vba.general)
  • Re: Send a fax from VBA
    ... Public Sub FaxeFeuille(FeuilleAFaxer As String, destinataire As String, ... Dim keys As String ... (This would not be needed if the assistant is already ... > Then you would use the Sendkeys statement to TAB to the required textbox ...
    (microsoft.public.excel.programming)
  • Re: SendKeys not working
    ... and fail otherwise. ... Have you tried inserting a delay in the code after each send keys? ... enter at the pop-ups by using SendKeys at the appropriate point. ... only if the user has Exclusive permissions. ...
    (microsoft.public.access.modulesdaovba)
  • Re: Sendkeys to DOS application
    ... How would I send the keystrokes to the CMD.exe? ... Some command need to be processed before they reach the ... or other kind of method make use of Windows system message. ... but this yields the same results as the SendKeys method: ...
    (microsoft.public.dotnet.framework)