Code to export report to Excel & keep settings

P

Pamela

I created a cmd button using the wizard to send the specified report. We
then choose Excel as the format/program to write it and it automatically
opens Outlook at attaches our report as a spreadsheet to a New Message. The
spreadsheet version of our report, however, doesn't keep the landscape
setting. I tried searching for help on it and found some code that looked
similar to what I am trying to accomplish and pasted it into my OnClick
event, but it isn't working...Please Help!! How can I do this all
automatically?? Thanks so much!

Here's is my code:
Private Sub MailtoTim_Click()
On Error GoTo Err_MailtoTim_Click

Dim stDocName As String

stDocName = "rpt_OpenAssnsAll"
DoCmd.SendObject acReport, stDocName
appxls.ActiveSheet.PageSetup.PrintArea = ""
With appxls.ActiveSheet.PageSetup
.Orientation = xlLandscape
End With


Exit_MailtoTim_Click:
Exit Sub

Err_MailtoTim_Click:
MsgBox Err.Description
Resume Exit_MailtoTim_Click

End Sub

Thanks again!
Pamela
 

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