Archive for December 2010

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

MS Access VBA Developer Code

Just to announce that I intend to use this space to put any interesting VB code I come across or use.  If anyone would like to contribute, then please do!

|