Results 1 to 3 of 3
  1. #1
    sombiatz is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    3

    Export File Name with Today's Date

    Hi All,

    I have been working with my boss on an access database that compiles a list of daily charges and creates an excel document in a shared folder. Currently, I am going into the database each day and running the macro my boss created. The file is created with the following name: MTProfessionalCharges.xlsx. I then have to go into the shared folder and change the excel file name with today's date. For example, today's file (6/10/14) would be renamed as "2014.06.10MTProfessionalCharges.xlsx." Is there a way alter the macro so the file name does not need to be changed? Attached is how the macro currently looks in Access 2010. I do not have a programming background so please simplify the solution as much as possible.

    Thanks!
    Martha
    Attached Files Attached Files

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    You would need to change the macro and add code.

    instead of running the ACTION transferspreadsheet, you must build a custom function that the macro can run..

    Code:
    public function ExportFile()
    dim vFile
    
    vFile = "c:\myfile\folder\"  & format(date(),"yyyy.mm.dd") & "MTprofessionalCharges.xlsx"
    
     DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, "BaseChargesQueryD", vFile, True
    end function
    the macro would RUNCODE ExportFile()

  3. #3
    sombiatz is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    3
    Thanks for the help. I tried to do what you said but it didn't work due to my lack of coding knowledge. I tried editing the macro to include a Run Code action. I didn't know how to go about creating the custom function so I opened the macro in Visual Basic and just copied and pasted the code you provided above. When I tried running the macro, I received an error message stating it could not find the function ExportFile().

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

Similar Threads

  1. Replies: 1
    Last Post: 11-26-2013, 09:25 AM
  2. Replies: 3
    Last Post: 06-18-2013, 01:14 PM
  3. Replies: 5
    Last Post: 10-12-2012, 11:00 AM
  4. Replies: 12
    Last Post: 04-26-2012, 04:01 AM
  5. Date/time export to CSV file
    By kaptin in forum Import/Export Data
    Replies: 3
    Last Post: 05-08-2011, 06:57 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