Results 1 to 6 of 6
  1. #1
    smc678 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    65

    How do I import an excel file to a table with out it being Linked?


    How do I import an excel file to a table with out it being Linked? I have a data base that works off of a table that is currently linked to a excel file. This file needs to be updated through out the day with all new data each time. But if i have the database open I cannot update the excel file. Is there a way I can just pull the data from the excel file?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,924
    You can import data with Import wizard or use VBA code to open an Excel object and read in the data to table one cell at a time or use VBA to establish the link when needed. http://social.msdn.microsoft.com/For...-a6489161091b/
    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.

  3. #3
    smc678 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    65
    Im receiving a run-time error 3918 Click image for larger version. 

Name:	Capture6.PNG 
Views:	14 
Size:	25.5 KB 
ID:	10942 ? this is the code i used.

    Private Sub Command22_Click()
    DoCmd.TransferSpreadsheet acImport, 3, _
    "TBLAgedCartons", "P:\Shared\AGED\crViewer.xls", True, "A:O"

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,924
    Not familiar with that error.

    Referencing cell range is tricky. Need the sheet name prefix. First try the import without the range reference. It is an optional argument
    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.

  5. #5
    smc678 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    65
    I dont get it. I used the other example and this is what is stoping the code. Any ideas?
    Private Sub Command22_Click()
    Dim strPathFile As String, strFile As String, strPath As String
    Dim strTable As String
    Dim blnHasFieldNames As Boolean
    ' Change this next line to True if the first row in EXCEL worksheet
    ' has field names
    blnHasFieldNames = True
    ' Replace C:\Documents\ with the real path to the folder that
    ' contains the EXCEL files
    strPath = "C:\Users\smc678\Documents\AGED"
    ' Replace tablename with the real name of the table into which
    ' the data are to be imported
    strTable = "TBLAgedCartons"
    strFile = Dir(strPath & "*.xls")
    Do While Len(strFile) > 0
    strPathFile = strPath & strFile
    DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, _
    strTable, strPathFile, blnHasFieldNames

    ' Uncomment out the next code step if you want to delete the
    ' EXCEL file after it's been imported
    ' Kill strPathFile
    strFile = Dir()
    Loop
    End Sub

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,924
    Step debug. Check the values of variables as the code runs. Review link at bottom of my post for guidance on debugging techniques.

    I think you will find that the concatenation of path and file strings are missing '\' character.

    BTW, yellow highlight is hard to read, use red.
    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. Updating a Linked Excel File via VBA
    By JoeM in forum Programming
    Replies: 7
    Last Post: 09-09-2015, 01:13 PM
  2. Replies: 2
    Last Post: 12-27-2012, 09:37 AM
  3. Excel Import - File with row spaces
    By Jackfam58 in forum Import/Export Data
    Replies: 1
    Last Post: 04-13-2011, 07:35 PM
  4. Import Excel File Using Macro?
    By oregoncrete in forum Import/Export Data
    Replies: 0
    Last Post: 04-05-2011, 12:26 PM
  5. #Num, Linked Excel File
    By Rick West in forum Import/Export Data
    Replies: 5
    Last Post: 02-04-2010, 10:50 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