Excelsend method inconsistent using Access 2003 and 2007

W

Worsty

Sorry for the duplicate post (I posted this in Excel group also), but
didn't know which would be more appropriate. Hope someone can help!

*******************************************


We have the following code in our application that we are calling on
the click of a button. As you can see it just sends the report
output
to Excel and then puts the excel document into an Outlook email as an
attachment.... or so it is supposed to. Problem is that it is
inconsistent. On some machines it works all the time and on others
it
works part of the time. It gets as far as the Msg Box "Do you want
to
e-mail this report" and then appears to skip over the rest of the
code
just taking you to the Access report view.

Has anyone had this issue and if so how did you fix it. We are using
both Access 2007 and 2003.


Thanks,


Public Function Excelsend()
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Msg = "Do you want to E-Mail this Report?" ' Define message.
Style = vbYesNo + vbCritical + vbDefaultButton1 ' Define buttons.
Title = "Warning" ' Define title.
Help = "" ' Define Help file.
Ctxt = 1000 ' Define topic
' context.
' Display message.
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
On Error GoTo err_showSendDialog
If Response = vbYes Then ' User chose Yes.
DoCmd.SendObject acReport, "", "MicrosoftExcel(*.xls)"
Else ' User chose No.
DoCmd.Close
exit_showSendDialog:
Exit Function
End If
err_showSendDialog:
If Err.Number = 2501 Then 'User Cancelled DoCmd
Resume exit_showSendDialog
Else 'Add your own error handling routine here
Resume exit_showSendDialog
Resume Next
End If
End Function
 

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