Problem running macro from command button

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?
 
G

Guest

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
 
G

Guest

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

Geoff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top