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

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
 
A

Alex Dybenko

you have to add a line:
on error resume next

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top