Results 1 to 3 of 3
  1. #1
    fintan06 is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2009
    Posts
    2

    Exclamation Transfer SpreadSheet Command and Rename


    Hello.

    I have a created a Macro and in it I am using the transfer spreadhseet command. I am using scheduler to run this macro and everything works fine. But what I would like to do in the macro is when it transfers the spreadsheet that it gives it a new spreadsheet name each time. I am not a VBA user and am an intermediate Access user and wondering can this be done or not



  2. #2
    dcrake's Avatar
    dcrake is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2009
    Posts
    435
    The best way to do this is run it in code.

    First convert your macro to vb

    Then decide on a naming convention, lets say you want to include today's date into the file name then do the following


    Dim sFile as string

    sFile = "Export_" & Format(Date(),"yymmdd") & ".xls"

    Now on the command line

    DoCmd.TransferSpreadsheet where the file name is hard coded replace that hard code with sFile.

    Then save this revised code to a public function, lets call it ExportToExcel

    Save this in a standard module

    Then create a new macro that uses the RunCommand option and when it asks you for the function name enter ExportToExcel.

    Finally assing ths new macro to be the one that the schedule fires off.

    David

  3. #3
    fintan06 is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2009
    Posts
    2

    Thumbs up Need more assistance

    Hey David.

    THanks for quick reposone, but could you possibly explain a little better even by using an example, I dont play with VB too much.

    I want to export it to a shared drive called X:\ and the format for the naming you had would be fine
    Example - TEST(10/15/2009).XLS

    Here is Query Sample

    Public Sub ExcelExport()
    Dim sFile As String
    sFile = "Export_" & Format(Date, "yymmdd") & ".xls"
    DoCmd.SetWarnings False
    ' Open UNION Query
    DoCmd.OpenQuery "UNION_ALL_TEAMS", acViewNormal, acEdit
    DoCmd.Close acQuery, "UNION_ALL_TEAMS"
    ' MAKE THE TABLE
    DoCmd.OpenQuery "MAKE_ALL_STAFF", acViewNormal, acEdit
    ' Export To Excel

    DoCmd.TransferSpreadsheet TransferType:=acExport, SpreadsheetType:=acSpreadsheetTypeExcel9, Tablename:="MAKE_ALL_STAFF", filename:="x:\Export_ & Format(Date, yymmdd) & .xls"
    DoCmd.SendObject acTable, "TEST_STAFF", "MicrosoftExcelBiff8(*.xls)", "TR@test.com", "", "", "TABLE UPDATED", "Weekly Table Updated", False, ""
    DoCmd.Quit acSave
    End Sub

    Where each time it exported it would enter the date in the format above.

    Thanks again.

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

Similar Threads

  1. On-Click event transfer
    By nkenney in forum Forms
    Replies: 16
    Last Post: 03-26-2009, 09:02 PM
  2. Transfer text
    By nshaikh in forum Import/Export Data
    Replies: 0
    Last Post: 09-11-2008, 03:27 AM
  3. importing excel spreadsheet issues
    By majortool in forum Import/Export Data
    Replies: 1
    Last Post: 01-24-2008, 06:29 PM
  4. Replies: 3
    Last Post: 04-23-2006, 09:09 PM
  5. File path name using Transfer spreadsheet
    By JohnN in forum Import/Export Data
    Replies: 0
    Last Post: 11-14-2005, 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