Results 1 to 11 of 11
  1. #1
    Jerry Lutz is offline Novice
    Windows 10 Office 365
    Join Date
    May 2021
    Posts
    11

    Renaming a Report when sending using sendobject

    I would like to append the current date and time to a report when using sendobject


    Current report name is Detailed List, and when using sendobject, the report does get attached with the name Detailed List.pdf

    I would like the report to have the file name attached using the current date and time appended to the name like: Detailed List May 20, 2021 12:30 PM.pdf

    This is the code I am using to sendobject

    DoCmd.SendObject acReport, "Detailed List", acFormatPDF, , , , "Subject", "Body", True, ""

    Is there a way to simply change the name of the report within the sendobject line of code ?

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    I doubt very much that you can do it easily if at all. I suppose you could code to create the object then add it to the reports collection and send it. If you didn't remove it you'd soon end up with many reports you don't need. Then there is the speculation that you'd be risking db corruption by modifying a collection over and over.

    Can you not get by with adding a field or label right in the report to show additional info, or modify the email subject line accordingly - or both?
    If there is a way to rename an Outlook attachment before sending that would be powerful but also likely very challenging to say the least.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    Jerry Lutz is offline Novice
    Windows 10 Office 365
    Join Date
    May 2021
    Posts
    11
    Quote Originally Posted by Micron View Post
    I doubt very much that you can do it easily if at all. I suppose you could code to create the object then add it to the reports collection and send it. If you didn't remove it you'd soon end up with many reports you don't need. Then there is the speculation that you'd be risking db corruption by modifying a collection over and over.

    Can you not get by with adding a field or label right in the report to show additional info, or modify the email subject line accordingly - or both?
    If there is a way to rename an Outlook attachment before sending that would be powerful but also likely very challenging to say the least.
    Thanks for your response Micron - the date and time are already in the report - however when the end user is receiving it and saving to a folder on their computer - there has to be a better way to be able to find the most recent report by name... I know they could always look at the file date... but seems it should be much easier

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,861
    Quote Originally Posted by Jerry Lutz View Post
    I would like to append the current date and time to a report when using sendobject
    Current report name is Detailed List, and when using sendobject, the report does get attached with the name Detailed List.pdf

    I would like the report to have the file name attached using the current date and time appended to the name like: Detailed List May 20, 2021 12:30 PM.pdf

    This is the code I am using to sendobject

    DoCmd.SendObject acReport, "Detailed List", acFormatPDF, , , , "Subject", "Body", True, ""

    Is there a way to simply change the name of the report within the sendobject line of code ?
    You could use Copy Object for the report, then use that to send, then Delete the report object?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    You could use Copy Object for the report, then use that to send, then Delete the report object?
    Is this a case of great minds thinking alike or is it fools seldom differ?
    I suppose you could code to create the object then add it to the reports collection and send it.
    Are they using Access to save this report or something else? I gather that it is Outlook.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Your original request was to do this in the SendObject method which it seems is possible if you're willing to include some code around it. See
    https://www.devhut.net/2012/08/16/ms...dobect-method/
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,861
    Nice find👏

  8. #8
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Thanks! Is that emoji a potato with eyes?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  9. #9
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,861
    Hands clapping? Or at least that is what I thought it was? Just had another look and that is what it is on my phone at least?

  10. #10
    Jerry Lutz is offline Novice
    Windows 10 Office 365
    Join Date
    May 2021
    Posts
    11
    Quote Originally Posted by Micron View Post
    Is this a case of great minds thinking alike or is it fools seldom differ?


    Are they using Access to save this report or something else? I gather that it is Outlook.
    Yes access is generating the report and using sendobject to email the report.

  11. #11
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,861
    Quote Originally Posted by Jerry Lutz View Post
    Yes access is generating the report and using sendobject to email the report.
    So Micron has given you the neatest solution you will find I believe.? I few extra lines of code?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Docmd.sendObject Sending email to specific folder
    By JeroenMioch in forum Access
    Replies: 29
    Last Post: 07-31-2015, 11:39 AM
  2. Replies: 3
    Last Post: 09-12-2013, 02:19 PM
  3. Renaming a report before SendObject
    By kingdoz in forum Reports
    Replies: 2
    Last Post: 11-17-2011, 08:22 PM
  4. Replies: 2
    Last Post: 09-29-2011, 10:57 AM
  5. Replies: 1
    Last Post: 11-17-2010, 11:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums