Wednesday, April 13, 2005

Opening Excel from MS Access thru VBA

This procedure opens up the excel sheet from a given directory and run a macro from within excel.

Private Sub CmdOpenframedetailedCombiner_Click()
Dim strPath As String
Dim strFileName As String
Dim strSourceDir As String
Dim strSheetName As String
Dim xlApp As Object
Dim xlSheet As Object

strSourceDir = "\\zwnwb080\Groups3\CDMAProd\PRODUCTION SERVICE SHEETS\daily web plan\"
strFileName = "frame and detailed combiner v7 with GSM Update.xls"
strPath = strSourceDir & strFileName
strSheetName = "detailed"

Set xlApp = CreateObject("Excel.Application")
With xlApp
.Visible = True
.Workbooks.Open strPath
.Run "UpdateDetailedFromForXlsdetailedQ"
End With
End Sub

1 comment:

a.p.r. pillai said...

This is a trick to Open an Excel file directly:

http://www.msaccesstips.com/2008/08/opening-excel-database-directly/

You can display Excel Cell Values directly on Form also:

http://www.msaccesstips.com/2008/08/display-excel-value-directly-on-form/