Results 1 to 2 of 2
  1. #1
    cjamesjust is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Sep 2014
    Posts
    1

    Change Excel Headings through Access VBA then import the file

    I've been able to find the code I need to import the file, but there are headers that come through from the group sending the excel file that will not import - they have a "." in them and that won't work. I need to find a way to remove the character and bring the excel header in line with the access table I'm importing to.

    I'm using the following to import the file:

    Sub Example()
    'the path to the excel workbook
    Dim strExcelPath As String
    strExcelPath = "C:\test\test\testing.xls"
    'import data from excel


    Call DoCmd.TransferSpreadsheet(acImport, _
    acSpreadsheetTypeExcel8, "testtable", strExcelPath, _
    True, "A1:AA11")
    End Sub

    and that work fine up until it hits the offending headers. what is a good, quick bit of code to plug in to alter the headers and what, if any references would need to be added?

    Kind of new to the whole VBA thing so I'm getting a lot from the web, but some things just aren't clear.



    Thanks,
    Chris

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,954
    VBA would have to open the Excel worksheet as an object that can be manipulated. http://stackoverflow.com/questions/1...ccess-2010-vba
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Import access query data into excel file, using excel vba
    By exceljockey in forum Import/Export Data
    Replies: 3
    Last Post: 11-15-2013, 02:36 PM
  2. Replies: 3
    Last Post: 12-06-2012, 03:47 PM
  3. Import to Access from Excel File created by ASP Page
    By tssrshot in forum Import/Export Data
    Replies: 3
    Last Post: 11-29-2012, 03:52 PM
  4. Replies: 1
    Last Post: 04-20-2012, 07:20 AM
  5. Import Excel file to Access
    By emmett in forum Import/Export Data
    Replies: 3
    Last Post: 04-06-2012, 05:27 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