Module that Opens a Excel File

BenSteckler

Addicted to Programming
Local time
Today, 22:22
Joined
Oct 4, 2000
Messages
44
Is there a command that opens a specific Excel File?
smile.gif
 
There is a series of commands to open an Excel:

************************
strFName = LCase(DBPath() & "\schdata.xls")
DoCmd OutputTo A_TABLE, "qfsubScheduleData", A_FORMATXLS, strFName, False
Main_ViewExcelFile strFName
******************
Sub Main_ViewExcelFile (ByVal strFile As String)
On Error GoTo Err_Main_ViewExcelFile

Dim objExcel As Object
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Open strFile
Set objExcel = Nothing
'Beep
'MsgBox "File " & strFile & " has been created. Please open the file using Excel.", MB_ICONINFORMATION

Exit_Main_ViewExcelFile:
Exit Sub

Err_Main_ViewExcelFile:
MsgBox "Error (" & Err & "): " & Error, MB_ICONExclamation
Resume Exit_Main_ViewExcelFile

End Sub
 
Alternatively, you could integrate the XL file in your table with the EXCEL! wizard (www.unsoftwareag.com). Then you can open your XL file with one button click.
 
A further option is to create a hyperlink address on a label, button or in code and follow the hyperlink.
 

Users who are viewing this thread

Back
Top Bottom