runtime error 2302 (1 Viewer)

odun

Registered User.
Local time
Yesterday, 23:54
Joined
Apr 24, 2005
Messages
108
Hello all,

I am getting this error when I use another machine, but it works fine on another machine, how do I ensure this code works on all machines:

Code:
Private Sub Command53_Click()
DoCmd.OutputTo acQuery, "QueryDetails", "MicrosoftExcel(*.xls)", "c:\ Query Details.xls", True, ""
End Sub

the error is:
Can't save the output data to the file you've selected.

The excel file is not open and it's not a template. Access creates the excel file everytime the code is runs and there is enough disk space.

Please help. Thanks!
 

ghudson

Registered User.
Local time
Today, 02:54
Joined
Jun 8, 2002
Messages
6,195
I noticed that your format option is odd. It should be "acFormatXLS"

The OutputTo function has other limitations. Why not use the TransferSpreadsheet() function?

I also noticed that you have a space in between the \ and the file name. "c:\ Query Details.xls"

OutputTo Method

TransferSpreadsheet Method

:D
 
Last edited:

odun

Registered User.
Local time
Yesterday, 23:54
Joined
Apr 24, 2005
Messages
108
Thanks.
Can you please help with the code for the transferspreadsheet function?

Thanks again.
 

odun

Registered User.
Local time
Yesterday, 23:54
Joined
Apr 24, 2005
Messages
108
Hello, I just tried the formatxls and I am getting a runtime error 13: type mismatch. here is the code I used:

Private Sub Command53_Click()
DoCmd.OutputTo acFormatXLS, "QueryDetails", "MicrosoftExcel(*.xls)", "c:\Query Details.xls", True, ""
End Sub
 

ghudson

Registered User.
Local time
Today, 02:54
Joined
Jun 8, 2002
Messages
6,195
Just follow the links I provided for each method. They will show you how to use each function. Your Outputo syntax is wrong. I also suggest you use the TransferSpreadsheet method instead.
 

l1ttledb

New member
Local time
Today, 07:54
Joined
Oct 1, 2009
Messages
3
Hi guys,

I have a similar problem although i know the code works on other machines. I get the 2302 when trying to output any files to excel.

"MyVar = MsgBox("Files are now ready to export", vbOKOnly, "EXPORT MESSAGE")
DoCmd.OutputTo acOutputQuery, "2 Pre Bar Call", acFormatXLS, "Pre Bar Call single.xls", True
DoCmd.OutputTo acOutputQuery, "3 POLREM 2 MOBILE", acFormatXLS, "Pre Bar Call multi.xls", True"

Any ideas?
Thanks
 

Users who are viewing this thread

Top Bottom