• exporting table to excel but with date in name

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » exporting table to excel but with date in name

    Author
    Topic
    #463730

    I have a macro that exports an access table to excel but I would like to an id number to the file name or todays date to the filename.

    Richard

    Viewing 0 reply threads
    Author
    Replies
    • #1184868

      I’d use VBA code, macros are hard to maintain. You can use an expression in the file name, for example:

      Dim strPath As String
      Dim strFile As String
      strPath = “C:Export”
      strFile = Format(Date, “yyyymmdd”) & “.xls”
      DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, “tblTest”, strPath & strFileName, True

      Note: you can’t use a date in the form 11/10/2009 in the file name, because slashes / aren’t allowed in file names.

      • #1184887

        I’d use VBA code, macros are hard to maintain. You can use an expression in the file name, for example:

        Dim strPath As String
        Dim strFile As String
        strPath = “C:Export”
        strFile = Format(Date, “yyyymmdd”) & “.xls”
        DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, “tblTest”, strPath & strFileName, True

        Note: you can’t use a date in the form 11/10/2009 in the file name, because slashes / aren’t allowed in file names.

        thanks again

    Viewing 0 reply threads
    Reply To: exporting table to excel but with date in name

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: