Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21243

VB6 and Excel loading then unloading immediately

$
0
0
First off I posted this here http://social.msdn.microsoft.com/For...forum=exceldevHowever I think this is the right forum for this.

We have an old VB6 application that uses data from and to Excel 97-2003 XLS and Access MDB. This application is slated to be updated to VS2012 and VB.NET. In the mean time I have a glitch that I cannot seem to find the issue. When we load the VB6 app it opens Excel 2010 in the background for getting and setting data. We are set to roll out Office 2010 on everyone’s system and I am still unable to find why it works fine on two systems and not on others. With Office 2007 everything seems to work just fine.

What happens is when I look at the processes in Task Manager on my Windows 7 Enterprise edition with Office Professional Plus 2010 system while loading the VB6 app I see?

EXCEL.EXE *32 | "My user name" | 00 CPU | 10,132k | Microsoft Excel

This is normal and stays in process the entire time I run it on my system. I also have this working on another end users system. However the issue and the fix I used on our two systems does not seem to work on other systems. I launch the VB6 app and it comes up.

EXCEL.EXE *32 | "My user name" | 00 CPU | 10,132k | Microsoft Excel

This loads in the processes and then immediately unloads without any errors. Then when I execute something that needs to use Excel I get.

Run-Time error ‘91’:

Object variable or With block variable not set.

This only happens if Excel unloads immediately otherwise the program works great. There are no events in any of the event logs and our other IT guy said it is loading and unloading normally with out crashing.

I have applied this to the systems http://support.microsoft.com/kb/926430/en-us . In all of my searching this looked like the best answer. However only two systems are working with Office Professional Plus 2010.

Here are the references and components.

References:
  • Visual Basic For Applications
  • Visual Basic runtime objects and procedures
  • Visual Basic objects and procedures
  • OLE Automation
  • Microsoft DAO 3.6 Object Library
  • Microsoft Excel 5.0 Object Library



Components:

Controls
  • Desaware Animated Button Control
  • Microsoft Common Dialog Control 6.0 (SP6)
  • Microsoft Data Bound Grid Control 5.0 (SP6)



Designers
  • Dat Environment
  • Data Report
  • DHTML Page
  • WebClass



Code:

Code:
    Public xlApp As Excel.Application
    Public WBSetup As Excel.Workbook 
    Public objWbCALC As Excel.Workbook
    Public objShtLEVELS As Excel.Worksheet

Sub Main()

    ' There is more code here that is not specific to Excel issue
   
    Set xlApp = Excel.Application
    ' Get the workbook.
    Set objWbCALC = xlApp.Workbooks.Open("c:\temp\Calc.xls")
    Set WBSetup = xlApp.Workbooks.Open("c:\temp\Setup.xls")
       
    ' Get worksheet
    Set objShtLEVELS = objWbCALC.Worksheets("Levels")

    ' There is more code here that is not specific to Excel issue
               
End Sub

This is working on one system that had Office 2007 and was upgraded to Office 2010. Working on my system with Office 2010. The EXE file is ran from the server you can install it or add the OCX files to local system and register them with regsvr32. No new components have been added or changed to the actual VB6 application. It seems to work on two systems and not on other systems.

However our test system have Office 2010 loaded on it and never had office 2007 on it. Maybe there is a residual left over file on it. Any ideas?

Viewing all articles
Browse latest Browse all 21243

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>