Results 1 to 4 of 4
  1. #1
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544

    Question Excel Export Tab Name


    I have the below "TransferSpreadsheet" command running. However, whenever it does run it names that tab "_CR2" instead of "CR2". Any idea why? I'm plum out. Thanks in advance!

    Code:
    DoCmd.TransferSpreadsheet acExport, , strTableName, strFileLoc & strFileName & strFileExt, True, "CR2"

  2. #2
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    The part you have in there with "CR2" should not be there. That is the RANGE argument and the helpfile even states:
    Quote Originally Posted by Access VBA Help File
    When you export to a spreadsheet, you must leave this argument blank. If you enter a range, the export will fail.
    You can rename the worksheet to what you want if you want to using this code:
    Code:
    Dim objXL As Object
    Dim xlWB As Object
     
    DoCmd.TransferSpreadsheet acExport, , strTableName, strFileLoc & strFileName & strFileExt, True
    Set objXL = CreateObject("Excel.Application")
    Set xlWB = objXL.Workbooks.Open(strFileLoc & strFilename & strFileExt)
     
    With xlWB
    .Worksheets(1).Name = "CR2"
    .Save
    .Close
    End With
     
    objXL.Quit
    Set objXL = Nothing

  3. #3
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    Interesting....I'll change my practices. I should mention that I have used this method a lot and it has never caused problems. Always naming my tabs as desired. Is it possible they added this feature with Access 2010? Thanks again for the information and advice.

  4. #4
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Quote Originally Posted by jgelpi16 View Post
    Interesting....I'll change my practices. I should mention that I have used this method a lot and it has never caused problems. Always naming my tabs as desired. Is it possible they added this feature with Access 2010? Thanks again for the information and advice.
    It hasn't changed anything I know of. The tab name normally takes on the name of the table or query which is being exported.

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

Similar Threads

  1. Export table to excel using excel template
    By allenjasonbrown@gmail.com in forum Programming
    Replies: 1
    Last Post: 06-27-2011, 02:10 AM
  2. Trying to export to Excel
    By BigCat in forum Programming
    Replies: 19
    Last Post: 05-19-2011, 01:49 AM
  3. Export from Access to Excel
    By Eowyne in forum Import/Export Data
    Replies: 5
    Last Post: 04-23-2011, 07:08 PM
  4. Macro to export to excel
    By jlclark4 in forum Import/Export Data
    Replies: 5
    Last Post: 04-15-2011, 08:36 AM
  5. Export to Excel
    By vaikz in forum Import/Export Data
    Replies: 3
    Last Post: 03-25-2009, 09:37 AM

Tags for this Thread

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