From an old post...
To open a specific excel file you can try using FollowHyperlink
Dim strFolderAndFile As String
strFolderAndFile = "C:\folder\newfile.xls"
Application.FollowHyperlink strFolderAndFile
In addition, if you want to invoke Automation Processes, and thereby
perform
operations on an excel file, from Access, use this code:
Option Compare Database
Option Explicit ' Use this to make sure your variables are defined
' One way to be able to use these objects throghout the Module is to
Declare
them
' Here and not in a Sub
Private objExcel As Excel.Application
Private xlWB As Excel.Workbook
Private xlWS As Excel.Worksheet
Sub Rep()
Dim strFile As String
strFile = "C:\Documents and Settings\ryan\Desktop\YourExcelFile.xls"
' Opens Excel and makes it Visible
Set objExcel = New Excel.Application
objExcel.Visible = True
'Opens up the Workbook
Set xlWB = objExcel.Workbooks.Open(strFile)
'Sets the Workseet to the last active sheet - Better to use the commented
version and use the name of the sheet.
Set xlWS = xlWB.ActiveSheet
'Set xlWS = xlWB("Sheet2")
With xlWS ' You are now working with the Named file and the named
worksheet
'Begin formatting, or whatever you want to do…your Excel code goes
here…VEEEEERYYY COOOOLLLL STUFFFF…
End With
'Do Close and Cleanup
End Sub
HTH,
Ryan---