Home All Groups Group Topic Archive Search About

Cannot creating Excel objects in Windows Vista

Author
11 May 2007 3:18 PM
Wyne
Hello,

I have a VB6 application which works very well with Windows 98, 2000 and XP.
It cantains a function that exports data to a Excel.Application object. The
codes are listed below:

------------------------------------------------------------------

Public Function ExportDataToExcel( ) as Integer

     On Error goto NotInstalled

   ' define objects:
    Dim ExWbk As Excel.Workbook
    Dim ExSht As Excel.Worksheet,
    Dim r As Excel.Range

    Set ExWbk = ExApp.Workbooks.Add
    Set ExSht = ExWbk.Worksheets(1)

    On Error goto ErrEscape

    Dim ii As Integer

    ExApp.DisplayAlerts = False
    ii = ExWbk.Worksheets.Count

   ' keep only one sheet:
    Do While ii > 2
        ExWbk.Worksheets(ii).Delete
        ii = ii - 1
    Loop

    '
    ExApp.DisplayAlerts = True
    '
    ' show the application:
    With ExApp
        .WindowState = xlNormal
        .Visible = True
        .Interactive = False
    End With

    Set r = ExSht.Range("A1:I1")

    With r.Font
        .Bold = True
        .Size = 22
        .Color = vbBlue
    End With


    With ExSht
        ii = ii + 1
        .Cells(ii, 2) = "Data A"
        .Cells(ii, 4) = "Data B"
        .Cells(ii, 6) = "Data C
        ...
        ...

   End With
   Exit Function

NotInstalled:
    MsgBox "Microsoft Excel program has not been installed in" & _
    "this computer, or it has been corrupted."
     Exit Function

ErrEscape:
    If (Not ExApp Is Nothing) Then ExApp.Quit

End Function
------------------------------------------------------------------------------

Now, I installed my program in a Windows Vista laptop, with Office 2003
installed and activated. Every time I invoke this function, I got a message:

     Run-time Error '50290':
     Application-defined or object-defined error

And the program crashs



Then, I installed VB6 IDE (Enterprise Edition) to this laptop, in hopes  to
capture  the error location in the codes. But every time this error happens,
the IDE crashed, too.

Can you provide any help about this?


Thanks in Advance.

Author
13 May 2007 8:06 AM
Mark Yudkin
I can't see the statement that actually instantiates Excel (ExApp), although
I suspect it's blowing up there.

Show quoteHide quote
"Wyne" <W***@discussions.microsoft.com> wrote in message
news:BDD58AA5-8D30-41C6-8FA5-9E8A190C81AB@microsoft.com...
> Hello,
>
> I have a VB6 application which works very well with Windows 98, 2000 and
> XP.
> It cantains a function that exports data to a Excel.Application object.
> The
> codes are listed below:
>
> ------------------------------------------------------------------
>
> Public Function ExportDataToExcel( ) as Integer
>
>     On Error goto NotInstalled
>
>   ' define objects:
>    Dim ExWbk As Excel.Workbook
>    Dim ExSht As Excel.Worksheet,
>    Dim r As Excel.Range
>
>    Set ExWbk = ExApp.Workbooks.Add
>    Set ExSht = ExWbk.Worksheets(1)
>
>    On Error goto ErrEscape
>
>    Dim ii As Integer
>
>    ExApp.DisplayAlerts = False
>    ii = ExWbk.Worksheets.Count
>
>   ' keep only one sheet:
>    Do While ii > 2
>        ExWbk.Worksheets(ii).Delete
>        ii = ii - 1
>    Loop
>
>    '
>    ExApp.DisplayAlerts = True
>    '
>    ' show the application:
>    With ExApp
>        .WindowState = xlNormal
>        .Visible = True
>        .Interactive = False
>    End With
>
>    Set r = ExSht.Range("A1:I1")
>
>    With r.Font
>        .Bold = True
>        .Size = 22
>        .Color = vbBlue
>    End With
>
>
>    With ExSht
>        ii = ii + 1
>        .Cells(ii, 2) = "Data A"
>        .Cells(ii, 4) = "Data B"
>        .Cells(ii, 6) = "Data C
>        ...
>        ...
>
>   End With
>   Exit Function
>
> NotInstalled:
>    MsgBox "Microsoft Excel program has not been installed in" & _
>    "this computer, or it has been corrupted."
>     Exit Function
>
> ErrEscape:
>    If (Not ExApp Is Nothing) Then ExApp.Quit
>
> End Function
> ------------------------------------------------------------------------------
>
> Now, I installed my program in a Windows Vista laptop, with Office 2003
> installed and activated. Every time I invoke this function, I got a
> message:
>
>     Run-time Error '50290':
>     Application-defined or object-defined error
>
> And the program crashs
>
>
>
> Then, I installed VB6 IDE (Enterprise Edition) to this laptop, in hopes
> to
> capture  the error location in the codes. But every time this error
> happens,
> the IDE crashed, too.
>
> Can you provide any help about this?
>
>
> Thanks in Advance.
Are all your drivers up to date? click for free checkup

Author
14 May 2007 1:58 PM
Wyne
Hi Mark,

I forgot copy a line of code in my question. It actually has two lines

Dim ExApp as Excel.Application
Set ExApp = New Excel.Application

These two lines resides just after "On Error ..." staement.


Thanks you and look forward that you can give me further help regarding this
problem, other wise we cannot include the "Vista" in the platform list of our
products.


Does this problem come from some inherent incompatibilty between Vista and
previours version Windows?



Show quoteHide quote
"Mark Yudkin" wrote:

> I can't see the statement that actually instantiates Excel (ExApp), although
> I suspect it's blowing up there.
>
> "Wyne" <W***@discussions.microsoft.com> wrote in message
> news:BDD58AA5-8D30-41C6-8FA5-9E8A190C81AB@microsoft.com...
> > Hello,
> >
> > I have a VB6 application which works very well with Windows 98, 2000 and
> > XP.
> > It cantains a function that exports data to a Excel.Application object.
> > The
> > codes are listed below:
> >
> > ------------------------------------------------------------------
> >
> > Public Function ExportDataToExcel( ) as Integer
> >
> >     On Error goto NotInstalled
> >
> >   ' define objects:
> >    Dim ExWbk As Excel.Workbook
> >    Dim ExSht As Excel.Worksheet,
> >    Dim r As Excel.Range
> >
> >    Set ExWbk = ExApp.Workbooks.Add
> >    Set ExSht = ExWbk.Worksheets(1)
> >
> >    On Error goto ErrEscape
> >
> >    Dim ii As Integer
> >
> >    ExApp.DisplayAlerts = False
> >    ii = ExWbk.Worksheets.Count
> >
> >   ' keep only one sheet:
> >    Do While ii > 2
> >        ExWbk.Worksheets(ii).Delete
> >        ii = ii - 1
> >    Loop
> >
> >    '
> >    ExApp.DisplayAlerts = True
> >    '
> >    ' show the application:
> >    With ExApp
> >        .WindowState = xlNormal
> >        .Visible = True
> >        .Interactive = False
> >    End With
> >
> >    Set r = ExSht.Range("A1:I1")
> >
> >    With r.Font
> >        .Bold = True
> >        .Size = 22
> >        .Color = vbBlue
> >    End With
> >
> >
> >    With ExSht
> >        ii = ii + 1
> >        .Cells(ii, 2) = "Data A"
> >        .Cells(ii, 4) = "Data B"
> >        .Cells(ii, 6) = "Data C
> >        ...
> >        ...
> >
> >   End With
> >   Exit Function
> >
> > NotInstalled:
> >    MsgBox "Microsoft Excel program has not been installed in" & _
> >    "this computer, or it has been corrupted."
> >     Exit Function
> >
> > ErrEscape:
> >    If (Not ExApp Is Nothing) Then ExApp.Quit
> >
> > End Function
> > ------------------------------------------------------------------------------
> >
> > Now, I installed my program in a Windows Vista laptop, with Office 2003
> > installed and activated. Every time I invoke this function, I got a
> > message:
> >
> >     Run-time Error '50290':
> >     Application-defined or object-defined error
> >
> > And the program crashs
> >
> >
> >
> > Then, I installed VB6 IDE (Enterprise Edition) to this laptop, in hopes
> > to
> > capture  the error location in the codes. But every time this error
> > happens,
> > the IDE crashed, too.
> >
> > Can you provide any help about this?
> >
> >
> > Thanks in Advance.
>
>
>
Author
14 May 2007 5:24 PM
Mark Yudkin
I think it's more likely to be an Excel issue than a Vista one. Please try
using CreateObject ("Excel.Application") and then stare at the content of
ExApp in the debugger. Usually it's best to declare everything as an Object
when dealing with Excel, so you should try that too.

Show quoteHide quote
"Wyne" <W***@discussions.microsoft.com> wrote in message
news:04BC6E49-3003-40AB-8FA8-30E73D2C81DB@microsoft.com...
> Hi Mark,
>
> I forgot copy a line of code in my question. It actually has two lines
>
> Dim ExApp as Excel.Application
> Set ExApp = New Excel.Application
>
> These two lines resides just after "On Error ..." staement.
>
>
> Thanks you and look forward that you can give me further help regarding
> this
> problem, other wise we cannot include the "Vista" in the platform list of
> our
> products.
>
>
> Does this problem come from some inherent incompatibilty between Vista and
> previours version Windows?
>
>
>
> "Mark Yudkin" wrote:
>
>> I can't see the statement that actually instantiates Excel (ExApp),
>> although
>> I suspect it's blowing up there.
>>
>> "Wyne" <W***@discussions.microsoft.com> wrote in message
>> news:BDD58AA5-8D30-41C6-8FA5-9E8A190C81AB@microsoft.com...
>> > Hello,
>> >
>> > I have a VB6 application which works very well with Windows 98, 2000
>> > and
>> > XP.
>> > It cantains a function that exports data to a Excel.Application object.
>> > The
>> > codes are listed below:
>> >
>> > ------------------------------------------------------------------
>> >
>> > Public Function ExportDataToExcel( ) as Integer
>> >
>> >     On Error goto NotInstalled
>> >
>> >   ' define objects:
>> >    Dim ExWbk As Excel.Workbook
>> >    Dim ExSht As Excel.Worksheet,
>> >    Dim r As Excel.Range
>> >
>> >    Set ExWbk = ExApp.Workbooks.Add
>> >    Set ExSht = ExWbk.Worksheets(1)
>> >
>> >    On Error goto ErrEscape
>> >
>> >    Dim ii As Integer
>> >
>> >    ExApp.DisplayAlerts = False
>> >    ii = ExWbk.Worksheets.Count
>> >
>> >   ' keep only one sheet:
>> >    Do While ii > 2
>> >        ExWbk.Worksheets(ii).Delete
>> >        ii = ii - 1
>> >    Loop
>> >
>> >    '
>> >    ExApp.DisplayAlerts = True
>> >    '
>> >    ' show the application:
>> >    With ExApp
>> >        .WindowState = xlNormal
>> >        .Visible = True
>> >        .Interactive = False
>> >    End With
>> >
>> >    Set r = ExSht.Range("A1:I1")
>> >
>> >    With r.Font
>> >        .Bold = True
>> >        .Size = 22
>> >        .Color = vbBlue
>> >    End With
>> >
>> >
>> >    With ExSht
>> >        ii = ii + 1
>> >        .Cells(ii, 2) = "Data A"
>> >        .Cells(ii, 4) = "Data B"
>> >        .Cells(ii, 6) = "Data C
>> >        ...
>> >        ...
>> >
>> >   End With
>> >   Exit Function
>> >
>> > NotInstalled:
>> >    MsgBox "Microsoft Excel program has not been installed in" & _
>> >    "this computer, or it has been corrupted."
>> >     Exit Function
>> >
>> > ErrEscape:
>> >    If (Not ExApp Is Nothing) Then ExApp.Quit
>> >
>> > End Function
>> > ------------------------------------------------------------------------------
>> >
>> > Now, I installed my program in a Windows Vista laptop, with Office 2003
>> > installed and activated. Every time I invoke this function, I got a
>> > message:
>> >
>> >     Run-time Error '50290':
>> >     Application-defined or object-defined error
>> >
>> > And the program crashs
>> >
>> >
>> >
>> > Then, I installed VB6 IDE (Enterprise Edition) to this laptop, in hopes
>> > to
>> > capture  the error location in the codes. But every time this error
>> > happens,
>> > the IDE crashed, too.
>> >
>> > Can you provide any help about this?
>> >
>> >
>> > Thanks in Advance.
>>
>>
>>

Bookmark and Share