/ Published in: Visual Basic
This code allows you to open an Excel workbook from an Access database and run macros within the target workbook. This could be used to format / clean data prior to import for example.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
Public Function OpenExcelTarget() Dim xl As Object 'Step 1: Start Excel, then open the target workbook. Set xl = CreateObject("Excel.Application") xl.Workbooks.Open ("C:\Full_path_of_excel_file.xls") 'Step 2: Make Excel visible xl.Visible = True 'Step 3: Run the target macro xl.Run "ReplaceEmpty" 'Step 4: Close and save the workbook, then close Excel xl.ActiveWorkbook.Close (True) xl.Quit 'Step 5: Memory Clean up. Set xl = Nothing End Function