Export to Excel

  • Thread starter P-chu via AccessMonster.com
  • Start date
P

P-chu via AccessMonster.com

I seen many suggestions on this, but could someone see what might be wrong
with this. I can't seem to make the file go to the right location.

DoCmd.OutputTo acQuery, stDocName, acFormatXLS, stDocName & ".xls", "c:\
Savings\qrySavings.xls", True

It's got to be something simple I am overlooking.

Thanks much.
 
N

NoodNutt

G'day

Try this

DoCmd.SendObject acQuery, stDocName, acFormatXLS, stDocName & ".xls",
"C:\Savings\qrySavings.xls", True

HTH
Mark.
 
S

Stuart McCall

P-chu via AccessMonster.com said:
I seen many suggestions on this, but could someone see what might be wrong
with this. I can't seem to make the file go to the right location.

DoCmd.OutputTo acQuery, stDocName, acFormatXLS, stDocName & ".xls", "c:\
Savings\qrySavings.xls", True

It's got to be something simple I am overlooking.

Thanks much.

Looks to me like stDocName contains "qrySavings". If so, your line should
be:

DoCmd.OutputTo acQuery, stDocName, acFormatXLS,"c:\Savings\qrySavings.xls",
True
 
P

P-chu via AccessMonster.com

Thank you for your quick response, but this sends the file to an e-mail,
which is a really neat concept. However, I really need it to be saved in the
C:\Savings folder. There error I get when I click on the shortcut button is
"An expression you entered is the wrong data type for one of the arguments".
This only happens when I put in the file location. If no file location is
listed, it goes to the directory path of where the database is located. Any
other thoughts?

Thanks.
 
P

P-chu via AccessMonster.com

Awesome, that did it. Thanks so much.

Stuart said:
I seen many suggestions on this, but could someone see what might be wrong
with this. I can't seem to make the file go to the right location.
[quoted text clipped - 5 lines]
Thanks much.

Looks to me like stDocName contains "qrySavings". If so, your line should
be:

DoCmd.OutputTo acQuery, stDocName, acFormatXLS,"c:\Savings\qrySavings.xls",
True
 
S

Stuart McCall

P-chu via AccessMonster.com said:
Awesome, that did it. Thanks so much.
<snip>

No problem, glad you got it going. For future reference, here's how you
could have sussed it yourself: in the code window, right-click on the first
argument (in this case acQuery) and select 'Parameter info'. As you move the
text cursor along the line, the current argument you're pointing to will
become bold in the tooltip. This indicates what you're putting where in the
command.

HTH
 

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