Viewing an Excel file from Access database

This is a useful little subroutine, as it opens a file (given as a parameter) into Excel, and displays it, without having to have the Excel reference set.  However, do make sure that the Microsoft DAO 3.6 Object Library is set.  It works with Access 2000 and later.

Sub OpenExcelFile(ExcelFileName) 
Dim xlApp as Object
Dim xlWorkBook as Object
Set xlApp = CreateObject(”Excel.Application”)
Set xlWorkbook = xlApp.Workbooks.Open(ExcelFileName)
xlApp.DisplayAlerts = False
xlApp.visible = True
End Sub

Leave a Reply

You must be logged in to post a comment.