Code working in one sub routine, but not another

G

Guest

I am using the following code in 2 separate sub routines:

Dim xlApp As New myExcel.Application
Dim xlBook As New myExcel.Workbook
Dim xlSheet As New myExcel.Worksheet

xlBook = xlApp.Workbooks.Add
xlSheet = xlBook.Worksheets.Add

In one subroutine it works fine, in the second subroutine, i get a
"Additional information: COM object with CLSID
{00020819-0000-0000-C000-000000000046} is either not valid or not
registered." error.

Any ideas?
 
G

Guest

On the second line, the " Dim xlBook As New myExcel.Workbook"

but i don't know why as the exact same code works in another subroutine in
the same class
 

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