I am trying to open a user chosen excel file from an access 2007 program. The code will open a excel file perform some data manipulation then save and close the excel program. At this time I am stuck with how to open the excel file. The following code does not open excel it just crashes then I get a runtime error Automation error The remote procedure call failed.
Function Pbuseconversion()
Dim f As Object
Dim myfile As String
Dim objXLApp As Object
Dim objXLBook As Object
Set appExcel = Nothing
Set f = Nothing
myfile = ""
Set f = Application.FileDialog(3)
f.Title = "Select FMS Data file."
f.filters.Add "xls", "*.xls"
f.AllowMultiSelect = False
f.Show
With f
myfile = .SelectedItems(1)
End With
Set objXLApp = CreateObject("Excel.Application")
Set objXLBook = objXLApp.Workbooks.Open(myfile)
objXLApp.Application.Visible = True
Set appExcel = Nothing
Set f = Nothing
myfile = ""
End Function
please help, thx
Function Pbuseconversion()
Dim f As Object
Dim myfile As String
Dim objXLApp As Object
Dim objXLBook As Object
Set appExcel = Nothing
Set f = Nothing
myfile = ""
Set f = Application.FileDialog(3)
f.Title = "Select FMS Data file."
f.filters.Add "xls", "*.xls"
f.AllowMultiSelect = False
f.Show
With f
myfile = .SelectedItems(1)
End With
Set objXLApp = CreateObject("Excel.Application")
Set objXLBook = objXLApp.Workbooks.Open(myfile)
objXLApp.Application.Visible = True
Set appExcel = Nothing
Set f = Nothing
myfile = ""
End Function
please help, thx