Help Access 2007 macro to open a excel file

dinfinity

Registered User.
Local time
Today, 06:28
Joined
Mar 3, 2011
Messages
11
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
 
Just tried your code in 2007.Did not error but left the open excel workbook on the taskbar.
 
I do not have admin rights to this computer and I am starting to wonder if that is my issue. I have tried all kinds of diffrent code combinations and continue to run into various excel crashes.

OS Vista
 
Here are the details of the excel crash
Problem signature:
Problem Event Name: APPCRASH
Application Name: EXCEL.EXE
Application Version: 12.0.6545.5000
Application Timestamp: 4c654035
Fault Module Name: StackHash_23c5
Fault Module Version: 6.0.6002.18327
Fault Module Timestamp: 4cb73436
Exception Code: c0000374
Exception Offset: 000b06fc
OS Version: 6.0.6002.2.2.0.256.4
Locale ID: 1033
Additional Information 1: 23c5
Additional Information 2: 75c6af9c2878ca0074996d68501c520a
Additional Information 3: da33
Additional Information 4: 964b799b0e0768bbefd9b55081948842


Any ideas?
 

Users who are viewing this thread

Back
Top Bottom