Problem running macro from command button

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form set up with a command button that I want to run an external
program, then run a macro to import the data that is generated by the
program. The code I have for the command button is as follows:

Private Sub cmdAddProducts_Click()
On Error GoTo Err_cmdAddProducts_Click

Dim stAppName As String
Dim stDocName As String

stAppName = "C:\WebPageGen\AddProducts.exe"
Call Shell(stAppName, 1)

stDocName = "ImportProducts"
DoCmd.RunMacro stDocName

Exit_cmdAddProducts_Click:
Exit Sub

Err_cmdAddProducts_Click:
MsgBox Err.Description
Resume Exit_cmdAddProducts_Click

End Sub

For some reason, the external VB program runs fine, but the macro doesn't
run. I know the macro is good, it runs by itself. I've tried programming the
macro into a separate command button, and that works fine. I don't want to
have to use two separate buttons, I want to run both the program and the
macro with one button press. Can anyone suggest why the above code won't work?
 
Hi Trish,

You might want to add to your line:
DoCmd.RunMacro stDocName, True

The macro may need to wait for your prior function to finish before it can
trigger.

Geoff
 
Please disregard my prior send. I mixed up my SendKeys with my Macros..
1000 pardons.

Geoff
 
Back
Top