ACC: Wait Argument in SendKeys May Not Stop Macro Processing (95449)



The information in this article applies to:

  • Microsoft Access 1.0
  • Microsoft Access 1.1
  • Microsoft Access 2.0

This article was previously published under Q95449

SYMPTOMS

Advanced: Requires expert coding, interoperability, and multiuser skills.

When a macro calls the SendKeys action with the Wait parameter set to Yes, the macro will continue before the program that processed the keystrokes has finished performing the action that it was called to do.

RESOLUTION



To work around this behavior, have the macro call an Access Basic function or procedure that checks to see if the other application is finished. To correct the situation described above, you can do the following:

   Macro Action
   ------------
   RunApp                - Start Microsoft Excel
   SendKeys              - Start the macro
   RunCode               - Call a module that continues checking until
                           the file exists
   TransferSpreadsheet   - Import the spreadsheet
				

MORE INFORMATION

For example, suppose you want to create a macro that will call Microsoft Excel to make a file and then process that file after Microsoft Excel has created it. The Microsoft Access macro calls RunApp to start Microsoft Excel, then calls SendKeys to start a Microsoft Excel macro with the Wait parameter set to Yes. Microsoft Access will wait until the key strokes are processed, then continue if the Microsoft Excel macro has not finished creating the file. Microsoft Access will not wait for Microsoft Excel, and will fail when it tries to use the file.

The SendKeys action in Microsoft Access has two arguments: the first argument indicates which keystrokes to send; the second argument causes Microsoft Access to pause until the keystrokes are processed.

The description of the Wait argument on page 432 of the Microsoft Access "Language Reference" manual is misleading. If Wait is Yes, Microsoft Access will only wait until the keystrokes are processed. It will not wait until the application that the keystrokes were sent to is finished.

For more information about checking for a process to finish, please see the following article in the Microsoft Knowledge Base:

99940 ACC: How to Wait for a Shelled Process to Finish


Modification Type:MajorLast Reviewed:5/9/2003
Keywords:kbprb kbusage KB95449