Is there a way to load or read excel files to Access DB without opening it and could you provide some examples ?
Is there a way to load or read excel files to Access DB without opening it and could you provide some examples ?
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.
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 ?
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.
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
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.