Results 1 to 6 of 6
  1. #1
    johnseito is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    419

    Load or write xlsx file to DB without opening it ?


    Is there a way to load or read excel files to Access DB without opening it and could you provide some examples ?

  2. #2
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    What do you mean by open it?

    You can open the file with vba code from access and process your spreadsheets without the user having to open the file themselves or even see Excel.

  3. #3
    johnseito is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    419
    Yes you are right and thanks for your response to me. Codes can open the file and process it however I was thinking not to have the code open it but just process it, can it do that ?

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Based on your original post, maybe you can just link your sheet(s) as Access tables?
    Or you can transfer them (either from Excel to Access or the other way around).
    Or you can use Automation to import data (which requires you to open the file but not necessarily show it to anyone).
    Your requirements and process are somewhat vague.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    Here's some example code that might help get you started:

    Code:
    Sub ProcessExcelFile()
    'Need to reference the excel object library for this code to work
    '  Go to Tools -> References -> Microsoft Excel 16.0 Object Library
    
    On Error GoTo ErrHandler
        Dim ex As Excel.Application
        Dim wb As Excel.Workbook
        
        Set ex = CreateObject("Excel.Application")
        Set wb = ex.Workbooks.Open("C:\<PATH TO YOUR EXCEL FILE HERE>.xlsx")
        
        'BEGIN Processing your excel file
        
        MsgBox wb.Worksheets("Sheet1").Range("A1")
        
        
        
        'END Processing your excel file
        
        wb.Close True 'Set this to true to save changes, false to discard changes
        
    ExitHandler:
        ex.Quit
        Set wb = Nothing
        Set ex = Nothing
        Exit Sub
        
    ErrHandler:
        MsgBox "Error in ProcessExcelFile sub. #" & Err.Number & " " & Err.Description
        Resume ExitHandler
    End Sub

  6. #6
    johnseito is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    419
    I understand and have done open and import. I haven’t done linking but will try that when get the chance. Thanks for your advice and example codes.

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

Similar Threads

  1. VBA to load xlsx into ACCESS without opening it
    By johnseito in forum Programming
    Replies: 13
    Last Post: 10-25-2017, 07:25 PM
  2. Export .xlsx file to internet address
    By Back2Basics in forum Import/Export Data
    Replies: 4
    Last Post: 04-09-2015, 03:58 AM
  3. vba to Export Multiple Sheets to xlsx File
    By jhrBanker in forum Import/Export Data
    Replies: 3
    Last Post: 09-23-2013, 01:00 PM
  4. Replies: 6
    Last Post: 07-23-2013, 11:57 AM
  5. Open Excel .xlsx file from Access
    By Bigmix in forum Programming
    Replies: 6
    Last Post: 02-28-2012, 09:55 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