Home All Groups Group Topic Archive Search About

Code working in one sub routine, but not another

Author
27 Jun 2006 12:11 PM
Jonathan Smith
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?

Author
27 Jun 2006 2:40 PM
Ahmed
Where exactly does it fail/throw the exception?

Jonathan Smith wrote:
Show quoteHide quote
> 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?
Author
27 Jun 2006 2:48 PM
Jonathan Smith
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

Show quoteHide quote
"Ahmed" wrote:

> Where exactly does it fail/throw the exception?
>
> Jonathan Smith wrote:
> > 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?
>
>