Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exporting to Excel from VBA code

Status
Not open for further replies.

JoanieB

Programmer
Apr 17, 2001
57
0
0
US
I export queries/tables using the docmd. Sometimes it runs through without a problem, other times I get an error message saying the "OutputTo" I selected is not available. I have tried checking for instance of Excel already running, but it did not solve the problem. What happens is, it gives me the option to debug or end and then when I debug, it lets me step through and exports fine.
Here is my code:

Dim stDocName As String
Dim stLinkCriteria As String

DoCmd.SetWarnings False
J05Date = Format(Date, "mmddyy")

SFile = "s:\SmallDifferences\Finished" & J05Date & ".xls"

DoCmd.OutputTo acOutputTable, "TblFinished", acFormatXLS, SFile

Sfile is defined publicly.
Sometimes it stops, sometimes it doesn't. Any ideas?
 
Also - there is NO way anyone could be in the file when the program is running. The output does not write over an existing file - here is where it is being created.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top