Tom,
Your suggestion works great. The only issue is if a I click Cancel in the
Output to prompt, I will get an error message stating Output to has been
canceled. I am currently using On Error Resume Next code before the docmd.
I try to avoid this code as much as I can, is there anothe method to use?
Thanks a lot!
Matt
> Hi Matt,
>
[quoted text clipped - 18 lines]
> Thanks,
> Matt
Tom Wickerath - 14 Feb 2005 01:58 GMT
Hi Matt,
Sure, all you need to do is trap for error 2501, and do nothing as a response. Notice that there
is no message box statement in the error handler for Case 2501:
Option Compare Database
Option Explicit
Sub ExportToExcel()
On Error GoTo ProcError
DoCmd.OutputTo ObjectType:=acOutputQuery, ObjectName:="qryFiles", _
OutputFormat:=acFormatXLS, AutoStart:=False
ExitProc:
Exit Sub
ProcError:
Select Case Err.Number
Case 2501 ' User clicked on cancel
Case Else
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure ExportToExcel..."
End Select
Resume ExitProc
End Sub
________________________________
Tom,
Your suggestion works great. The only issue is if a I click Cancel in the
Output to prompt, I will get an error message stating Output to has been
canceled. I am currently using On Error Resume Next code before the docmd.
I try to avoid this code as much as I can, is there anothe method to use?
Thanks a lot!
Matt
"Tom Wickerath" wrote:
> Hi Matt,
>
[quoted text clipped - 18 lines]
> Thanks,
> Matt
Tom Wickerath - 14 Feb 2005 02:33 GMT
2nd attempt to post reply (a reply posted over 30 minutes ago is still not showing up in my
newsreader)...
Hi Matt,
Sure, all you need to do is trap for error 2501, and do nothing as a response. Notice that there
is no message box statement in the error handler for Case 2501:
Option Compare Database
Option Explicit
Sub ExportToExcel()
On Error GoTo ProcError
DoCmd.OutputTo ObjectType:=acOutputQuery, ObjectName:="qryFiles", _
OutputFormat:=acFormatXLS, AutoStart:=False
ExitProc:
Exit Sub
ProcError:
Select Case Err.Number
Case 2501 ' User clicked on cancel
Case Else
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure ExportToExcel..."
End Select
Resume ExitProc
End Sub
________________________________
Tom,
Your suggestion works great. The only issue is if a I click Cancel in the
Output to prompt, I will get an error message stating Output to has been
canceled. I am currently using On Error Resume Next code before the docmd.
I try to avoid this code as much as I can, is there anothe method to use?
Thanks a lot!
Matt
I am trying to find an alternative to TransferSpreadsheet that will allow me
to format the Excel Data before it drops the file so that I can then use
SendObject to email the Formatted Excel Workbook.
Does this OutputTo method result in an Excel Object and how would I
reference that in VBA?
This is same issue I opened a thread on earlier this morning but am trying
to resolve with research.
Thanks in advance.

Signature
Jeff C
Live Well .. Be Happy In All You Do
> Hi Matt,
>
[quoted text clipped - 18 lines]
> Thanks,
> Matt
Arvin Meyer [MVP] - 30 May 2008 21:20 GMT
OutputTo is what happens in code when you use the menu object:
Tools >>> OfficeLinks >>> Analyze with Excel
DoCmd.OutputTo acOutputQuery, "QueryName", acFormatXLS, "C:\PathToFile",
True
The last argument (True) will open the resulting Excel file, from which you
can then do a File Send and get the Excel equivalent of SendObject.

Signature
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
>I am trying to find an alternative to TransferSpreadsheet that will allow
>me
[quoted text clipped - 35 lines]
>> Thanks,
>> Matt
Jeff C - 30 May 2008 21:49 GMT
Thanks Arvin: I am looping though a large dataset and am hoping to come up
with a way to format an Excel object before saving it as a file so I can
attach it as a variable in the SendObject method

Signature
Jeff C
Live Well .. Be Happy In All You Do
> OutputTo is what happens in code when you use the menu object:
>
[quoted text clipped - 44 lines]
> >> Thanks,
> >> Matt