S
Snowsride
Ken
You were good enough to provide the code below to open an Excel workbook:
Dim xlx As Object, xlw As Object, xls As Object, xlc As Object
On Error Resume Next
Set xlx = GetObject( , "Excel.Application")
If Err.Number <> 0 Then Set xlx = CreateObject("Excel.Application")
' Comment out the next line if you don't want EXCEL to be "seen" by user
xlx.Visible = True
Set xlw = xlx.workbooks.Open("C:\Filename.xls"), , False
Set xls = xlw.Worksheets("WorksheetName")
Set xlc = xls.Range("A1")
'
' do other things here
'
Set xlc = Nothing
Set xls = Nothing
xlw.Save
xlw.Close False
Set xlw = Nothing
xlx.Quit
Set xlx = Nothing
Two things...
Access highlights in red (error) the line Set xlw =
xlx.workbooks.Open("C:\Filename.xls"), , False - my solution was to delete
,,False Don't know what the parameters were for anyway!
The workbook has some code that runs on the Workbook_Open event that
includes Workbooks("MyWorkbook.xls").RefreshAll to refresh data links back to
the Access database that runs your code. The workbook opens but the
RefreshAll statement causes an error "ODBC MS Access Driver Login Failed"
'The database has been placed in a state by user 'Admin' on machine xxx that
prevents it from being opened or locked.'
If I click on the OK button I get a dialog box with a Login name field with
admin already entered and a blank field for a password.
If I substitute your code for the following:
Shell "c:\Program Files\Microsoft Office\Office\Excel.exe " _
& "c:\MyWorkbook.xls", vbMaximizedFocus
then it works OK but of course a new instance of Excel is opened each time
and if the user switches between Excel and Access to refresh the tables and
back to Excel multiple instances are created.
Hope you can follow the above and grateful for any help.
Regards
You were good enough to provide the code below to open an Excel workbook:
Dim xlx As Object, xlw As Object, xls As Object, xlc As Object
On Error Resume Next
Set xlx = GetObject( , "Excel.Application")
If Err.Number <> 0 Then Set xlx = CreateObject("Excel.Application")
' Comment out the next line if you don't want EXCEL to be "seen" by user
xlx.Visible = True
Set xlw = xlx.workbooks.Open("C:\Filename.xls"), , False
Set xls = xlw.Worksheets("WorksheetName")
Set xlc = xls.Range("A1")
'
' do other things here
'
Set xlc = Nothing
Set xls = Nothing
xlw.Save
xlw.Close False
Set xlw = Nothing
xlx.Quit
Set xlx = Nothing
Two things...
Access highlights in red (error) the line Set xlw =
xlx.workbooks.Open("C:\Filename.xls"), , False - my solution was to delete
,,False Don't know what the parameters were for anyway!
The workbook has some code that runs on the Workbook_Open event that
includes Workbooks("MyWorkbook.xls").RefreshAll to refresh data links back to
the Access database that runs your code. The workbook opens but the
RefreshAll statement causes an error "ODBC MS Access Driver Login Failed"
'The database has been placed in a state by user 'Admin' on machine xxx that
prevents it from being opened or locked.'
If I click on the OK button I get a dialog box with a Login name field with
admin already entered and a blank field for a password.
If I substitute your code for the following:
Shell "c:\Program Files\Microsoft Office\Office\Excel.exe " _
& "c:\MyWorkbook.xls", vbMaximizedFocus
then it works OK but of course a new instance of Excel is opened each time
and if the user switches between Excel and Access to refresh the tables and
back to Excel multiple instances are created.
Hope you can follow the above and grateful for any help.
Regards