export to multi-excel files

N

Newbie

Hello,
I have a monthly sales database w/~100 salespersons.
I like to export to 100 spreadsheets, ie. sales01.xls, sales02.xls...
I can do one by one for 100 times.
Is this possible just doing one time then get 100 spreadsheets?
and How?

Thanks
 
K

Klatuu

You can do this in VBA with a For Next Loop.
Two issues.
If the actual names are sales01.xls. sales02.xls, you will have a small
problem when you hit 100. I would suggest sales001.xls,
sales002.xls...sales100.xls

Is there a different query for each spreadsheet or is it one parameter
query? The latter is the better choice, but it can be done either way.

Here is the basic looping logic, but it does not address the FileName
argument of the TransferSpreadsheet.

Dim strPath As String
Dim strFileName As String
Dim lngCtr As Long

strPath = "\\Myserver\MyFolder\"

For lngCtr = 1 to 100
strFileName = strPath & "sales" & Format(lngCtr, "000") & ".xls"
DoCmd.TransferSpreadsheet, acExport, , "QueryName", strFileName, True
Next lngCtr

If you need help with creating the correct Query reference, post back.
 
N

Newbie

Thanks, I will try.


Klatuu said:
You can do this in VBA with a For Next Loop.
Two issues.
If the actual names are sales01.xls. sales02.xls, you will have a small
problem when you hit 100. I would suggest sales001.xls,
sales002.xls...sales100.xls

Is there a different query for each spreadsheet or is it one parameter
query? The latter is the better choice, but it can be done either way.

Here is the basic looping logic, but it does not address the FileName
argument of the TransferSpreadsheet.

Dim strPath As String
Dim strFileName As String
Dim lngCtr As Long

strPath = "\\Myserver\MyFolder\"

For lngCtr = 1 to 100
strFileName = strPath & "sales" & Format(lngCtr, "000") & ".xls"
DoCmd.TransferSpreadsheet, acExport, , "QueryName", strFileName, True
Next lngCtr

If you need help with creating the correct Query reference, post back.
 

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