Acess 2003- VBA runtime error 429 activx component can't create object

  • Thread starter Thread starter bILL
  • Start date Start date
B

bILL

Hi,
Using Access 2003 service pack 1.This once worked from
memory.
This code is part of a private module attached to a form.

Private Sub Open_Excel()
'Find and open the Excel workbook with
'the pricing for the variuos Selector sizes.
'The Workbook does not have to be visible.

'set up variables for working with excel.
Dim xlapp As excel.Application 'Excel
application Object
Dim xlbook As excel.Workbook 'Excel object-
workbook
Dim xlsheet As excel.Sheets 'excel worksheet
within the workbook

'create an Excel instance i.e set up an active
instance
'use an existing instance if there is one;otherwise
'create a new instance

Set xlapp = GetObject(, "Excel.application")
If Err.Number = 429 Then
'excel isn't running: create Excel Instance
Set xlapp = CreateObject("Excel.Application")
Err.Clear
End If


'Open relevant workbook and page
xlapp.Visible = False
xlbook = xlapp.Workbook.Open("C:\My
Documents\2WAYPRICES.xls")
xlapp.Sheets(2).Select

End Sub

Compiles ok but traps at error 429 activex component cant
create object at line,

Set xlapp = GetObject(, "Excel.application")

Even if Dim xlapp as object etc is used I get the same
error.

Any suggestions.
Perplexed.
Regards
bill
 
you have to add a line:
on error resume next

before this line:
Set xlapp = GetObject(, "Excel.application")
 
Back
Top