Name file at will prior to E-Mail

  • Thread starter Thread starter Randy
  • Start date Start date
R

Randy

I need the ability to name an excel file exported from a query at will prior
to E-Mailing. I have tried "sendobject" but the file created is exactly the
same name (Export Summary) as the query and then attached to outlook
express. This is fine except I need to name the excel file differently each
time. I need to run the query (Export Summary), export it to an excel file
to the filename of my choosing and then E-Mail the file. I can export the
query as an excel file to a folder on my computer, then manually rename the
file and then manually attach the file to an E-mail program. This is too
time consuming. Any Ideas..Thanks..Randy
 
If I read Help correctly, you don't have the option of naming the output
file with SendObject.

I think there are 2 possibilities you can use:

1. Use the CopyObject Method to copy the Query to a new Query with the
required name and then use the SendObject with the new Query name. After
that, use the DeleteObject Method to deleted the new Query (which is simply
a copy of your existing Query).

My guess is that this will bloat your database a bit so you may want to use
Compact-On-Close or at least compact your database regularly.

2. Use the TrasnferSpreadsheet Method to create the Excel file with the
required name. After that, use Outlook Automation (or other method to
"automate" the sending of e-mail such as CDO, etc ...) to send the e-mail
including the Excel file as an attachment.

This method will probably involve a fair bit of automation code so I
recommend this only if you are comfortable with VBA and can work your way
through. There are some articles on the Microsoft Support Web site if you
want to try:

http://support.microsoft.com/default.aspx?scid=FH;[LN];KBHOWTO
 
Thanks for the reply I'll give it a try...
Van T. Dinh said:
If I read Help correctly, you don't have the option of naming the output
file with SendObject.

I think there are 2 possibilities you can use:

1. Use the CopyObject Method to copy the Query to a new Query with the
required name and then use the SendObject with the new Query name. After
that, use the DeleteObject Method to deleted the new Query (which is
simply
a copy of your existing Query).

My guess is that this will bloat your database a bit so you may want to
use
Compact-On-Close or at least compact your database regularly.

2. Use the TrasnferSpreadsheet Method to create the Excel file with the
required name. After that, use Outlook Automation (or other method to
"automate" the sending of e-mail such as CDO, etc ...) to send the e-mail
including the Excel file as an attachment.

This method will probably involve a fair bit of automation code so I
recommend this only if you are comfortable with VBA and can work your way
through. There are some articles on the Microsoft Support Web site if you
want to try:

http://support.microsoft.com/default.aspx?scid=FH;[LN];KBHOWTO

--
HTH
Van T. Dinh
MVP (Access)




Randy said:
I need the ability to name an excel file exported from a query at will prior
to E-Mailing. I have tried "sendobject" but the file created is exactly the
same name (Export Summary) as the query and then attached to outlook
express. This is fine except I need to name the excel file differently each
time. I need to run the query (Export Summary), export it to an excel file
to the filename of my choosing and then E-Mail the file. I can export the
query as an excel file to a folder on my computer, then manually rename the
file and then manually attach the file to an E-mail program. This is too
time consuming. Any Ideas..Thanks..Randy
 
Back
Top