Running Macro - output pivot table to excel - error message 2046

B

Bob

I have a macro in which I am trying to output a pivot table to excel. When I
run the macro I get the following error message: The command or action
"output to" isnt avaialble now. Here is the VBA code of the macro:

Option Compare Database

'------------------------------------------------------------
' BDI_Macro1
'
'------------------------------------------------------------
Function BDI_Macro1()
On Error GoTo BDI_Macro1_Err

DoCmd.SetWarnings False
DoCmd.OpenQuery "BDI_Complete_By_FSE", acViewNormal, acEdit
Call Shell("", 1)
DoCmd.OutputTo acQuery, "BDI_Complete_By_FSE",
"MicrosoftExcelBiff8(*.xls)", "C:\Files\BDI_Complete By FSE", False, "", 0
DoCmd.Close acQuery, "BDI_Complete_By_FSE"
DoCmd.OpenQuery "BDI_Complete_By_FSE_Crosstab", acViewNormal, acEdit
Call Shell("", 1)
DoCmd.Close , ""
DoCmd.OpenQuery "BDI_by_FSE_Month", acViewPivotTable, acEdit
Call Shell("", 1)
DoCmd.OutputTo acQuery, "BDI_by_FSE_Month",
"MicrosoftExcelBiff8(*.xls)", "C:\Files\BDI FSE Month", False, "", 0
DoCmd.Close , ""
DoCmd.OpenQuery "BDI FSE YTD", acViewNormal, acEdit
Call Shell("", 1)
DoCmd.OutputTo acQuery, "BDI FSE YTD", "MicrosoftExcelBiff8(*.xls)",
"C:\Files\BDI FSE YTD", False, "", 0
DoCmd.Close , ""
DoCmd.OpenQuery "BDI by FSE Region Summary Month", acViewNormal, acEdit
Call Shell("", 1)
DoCmd.OutputTo acQuery, "BDI by FSE Region Summary Month",
"MicrosoftExcelBiff8(*.xls)", "C:\Files\BDI Region Summary Month", False, "",
0
DoCmd.Close acQuery, "BDI by FSE Region Summary Month"
DoCmd.OpenQuery "BDI by Region YTD", acViewNormal, acEdit
Call Shell("", 1)
DoCmd.OutputTo acQuery, "BDI by Region YTD",
"MicrosoftExcelBiff8(*.xls)", "C:\Files\BDI by Region YTD", False, "", 0
DoCmd.Close acQuery, "BDI by Region YTD"


BDI_Macro1_Exit:
Exit Function

BDI_Macro1_Err:
MsgBox Error$
Resume BDI_Macro1_Exit

End Function

I would like to know how I can correct this so that the pivot table outputs
to excel.
Thanks.
 

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