By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,446 Members | 3,031 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,446 IT Pros & Developers. It's quick & easy.

Export a query to Excel

P: n/a
Dear reader,

With the export command you can export a query to Excel.

By activate this command a form pop's up with the following text:

"The database object "Name.." already exist. Do you want to replace the
existing database object with the one you are exporting? If you want to
export this object without replacing the existing database object, click no.
You can then export the object again and rename it in the export dialog
box."

In case selecting [Yes] the Excel sheet with the same name will be replaced
and the other sheets in the Excel file remains unchanged. And this is watt I
want.

If I do the same with the following code:

DoCmd.OpenQuery "QueryName.."

DoCmd.RunCommand acCmdOutputToExcel

There is no warning that the Excel file exists and will be overwrite.

Is there code available with is doing the same as the "Export" command, only
replacing the Excel sheet with the same name as the query.

Thanks for any help.

Kind regards,

Simon
Feb 11 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Simon wrote:
Dear reader,

With the export command you can export a query to Excel.

By activate this command a form pop's up with the following text:

"The database object "Name.." already exist. Do you want to replace the
existing database object with the one you are exporting? If you want to
export this object without replacing the existing database object, click no.
You can then export the object again and rename it in the export dialog
box."

In case selecting [Yes] the Excel sheet with the same name will be replaced
and the other sheets in the Excel file remains unchanged. And this is watt I
want.

If I do the same with the following code:

DoCmd.OpenQuery "QueryName.."

DoCmd.RunCommand acCmdOutputToExcel

There is no warning that the Excel file exists and will be overwrite.

Is there code available with is doing the same as the "Export" command, only
replacing the Excel sheet with the same name as the query.

Thanks for any help.

Kind regards,

Simon

Don't know. But perhaps you could try TransferSpreadsheet instead.

Enter
TransferSpreadsheet
in a code module, highlight it, and press F1.

Feb 11 '07 #2

P: n/a
TransferSpreadsheet is for import (Excel to Access) I am looking for export
(Access to Excel)

"salad" <oi*@vinegar.comschreef in bericht
news:j6**************@newsread3.news.pas.earthlink .net...
Simon wrote:
Dear reader,

With the export command you can export a query to Excel.

By activate this command a form pop's up with the following text:

"The database object "Name.." already exist. Do you want to replace the
existing database object with the one you are exporting? If you want to
export this object without replacing the existing database object, click
no.
You can then export the object again and rename it in the export dialog
box."

In case selecting [Yes] the Excel sheet with the same name will be
replaced
and the other sheets in the Excel file remains unchanged. And this is
watt I
want.

If I do the same with the following code:

DoCmd.OpenQuery "QueryName.."

DoCmd.RunCommand acCmdOutputToExcel

There is no warning that the Excel file exists and will be overwrite.

Is there code available with is doing the same as the "Export" command,
only
replacing the Excel sheet with the same name as the query.

Thanks for any help.

Kind regards,

Simon
Don't know. But perhaps you could try TransferSpreadsheet instead.

Enter
TransferSpreadsheet
in a code module, highlight it, and press F1.

Feb 12 '07 #3

P: n/a

"Simon" <Sv********@Versatel.nlwrote in message
news:45***********************@news.tele2.nl...
Dear reader,

With the export command you can export a query to Excel.

By activate this command a form pop's up with the following text:

"The database object "Name.." already exist. Do you want to replace the
existing database object with the one you are exporting? If you want to
export this object without replacing the existing database object, click
no.
You can then export the object again and rename it in the export dialog
box."

In case selecting [Yes] the Excel sheet with the same name will be
replaced
and the other sheets in the Excel file remains unchanged. And this is watt
I
want.

If I do the same with the following code:

DoCmd.OpenQuery "QueryName.."

DoCmd.RunCommand acCmdOutputToExcel

There is no warning that the Excel file exists and will be overwrite.

Is there code available with is doing the same as the "Export" command,
only
replacing the Excel sheet with the same name as the query.

Thanks for any help.

Kind regards,

Simon

You mention about replacing the Excel sheet. Are you talking about the
worksheet (e.g. Sheet1, Sheet2 etc) or do you mean the Excel workbook (e.g.
C:\test\Book1.xls)?

If you mean you want to check if the workbook exists and prompt to replace
it, check out the "Dir" function in the VBA help file and write some code
using this function to check if the files exists.

You also replied to Salad that TransferSpreadsheet is for importing. I also
ask you to check the VBA help file for this command.

Jeff
Feb 12 '07 #4

P: n/a
Simon wrote:
TransferSpreadsheet is for import (Excel to Access) I am looking for export
(Access to Excel)
That's new to me. You should be able to import, link, or export.
>
"salad" <oi*@vinegar.comschreef in bericht
news:j6**************@newsread3.news.pas.earthlink .net...
>>Simon wrote:

>>Dear reader,

With the export command you can export a query to Excel.

By activate this command a form pop's up with the following text:

"The database object "Name.." already exist. Do you want to replace the
existing database object with the one you are exporting? If you want to
export this object without replacing the existing database object, click

no.
>>>You can then export the object again and rename it in the export dialog
box."

In case selecting [Yes] the Excel sheet with the same name will be

replaced
>>>and the other sheets in the Excel file remains unchanged. And this is

watt I
>>>want.

If I do the same with the following code:

DoCmd.OpenQuery "QueryName.."

DoCmd.RunCommand acCmdOutputToExcel

There is no warning that the Excel file exists and will be overwrite.

Is there code available with is doing the same as the "Export" command,

only
>>>replacing the Excel sheet with the same name as the query.

Thanks for any help.

Kind regards,

Simon


Don't know. But perhaps you could try TransferSpreadsheet instead.

Enter
TransferSpreadsheet
in a code module, highlight it, and press F1.


Feb 12 '07 #5

P: n/a
Transferspreadsheet goes both ways.
"Simon" <Sv********@Versatel.nlwrote in message
news:45***********************@news.tele2.nl...
TransferSpreadsheet is for import (Excel to Access) I am looking for
export
(Access to Excel)

"salad" <oi*@vinegar.comschreef in bericht
news:j6**************@newsread3.news.pas.earthlink .net...
>Simon wrote:
Dear reader,

With the export command you can export a query to Excel.

By activate this command a form pop's up with the following text:

"The database object "Name.." already exist. Do you want to replace the
existing database object with the one you are exporting? If you want to
export this object without replacing the existing database object,
click
no.
You can then export the object again and rename it in the export dialog
box."

In case selecting [Yes] the Excel sheet with the same name will be
replaced
and the other sheets in the Excel file remains unchanged. And this is
watt I
want.

If I do the same with the following code:

DoCmd.OpenQuery "QueryName.."

DoCmd.RunCommand acCmdOutputToExcel

There is no warning that the Excel file exists and will be overwrite.

Is there code available with is doing the same as the "Export" command,
only
replacing the Excel sheet with the same name as the query.

Thanks for any help.

Kind regards,

Simon

Don't know. But perhaps you could try TransferSpreadsheet instead.

Enter
TransferSpreadsheet
in a code module, highlight it, and press F1.


Feb 13 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.