LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Closing Excel with ActiveX causes problem

Hallo,

I am having a problem using ActiveX and Excel. I
am using NT 4.0, Service Pack 3, Excel 97, Service
Release SR1 and LabVIEW 5.1.

My LV application opens an Excel worksheet,
operates on the sheet and then closes it by using
ActiveX. Everything works fine until I try to
start Excel from the desktop after running my LV
application. Then I get an "Exception access
violation" generated by excel.exe. It seems like
my application does not manage to end the
excel.exe process which leads to the "violation
error" next time Excel is to be opened. To quit
Excel I call the "quit" method in
Excel_Application and then call the "Automation
Close".

Anyone knows how to solve this?

\Helena Dimitriou


Sent via Deja.com
http://www.deja.com/
Share what you know. Learn what you don't.
0 Kudos
Message 1 of 5
(3,263 Views)
> My LV application opens an Excel worksheet,
> operates on the sheet and then closes it by using
> ActiveX. Everything works fine until I try to
> start Excel from the desktop after running my LV
> application. Then I get an "Exception access
> violation" generated by excel.exe. It seems like
> my application does not manage to end the
> excel.exe process which leads to the "violation
> error" next time Excel is to be opened. To quit
> Excel I call the "quit" method in
> Excel_Application and then call the "Automation
> Close".
>

You don't normally have to do this, but you might try
checking to see if all ActiveX interfaces are closed
using a Close icon. Also, when accessing the interface
references from other properties and methods, try to
delete parallel act
ivities and branched wires. You can
also get access to a Release Variant icon that can be
used to release the interfaces.

Again, this shouldn't be necessary, but for now, with
the way LV variants work, there may be copies made on
interfaces references. This shouldn't lead to Excel
crashes, but it seems to under certain situations.

Greg McKaskle
Message 2 of 5
(3,263 Views)
I have seen similar thing happen with HiQ. Whnever there is an error in one
of the VI's from the VI chain, then subsequent VI's would not execute,
leading to open references hanging out there. The problem was noticable
when I would programmatically open HiQ, generate error and then try to close
HiQ manually. It always ends up in some kind of memory access violation
(under NT). Yeah and I remember having a bunch of problems with trying to
send data to Excell, after about 10 executions Excell was hurting. That was
a sideproject so I did not really care about it at the time.
All this happened with LV5.1 and NTSP4, SP5

> I am having a problem using ActiveX and Excel. I
> am using NT 4.0, Service Pack 3, Excel 97, Service
> Release SR1 and LabVIEW 5.1.
>
> My LV application o
pens an Excel worksheet,
> operates on the sheet and then closes it by using
> ActiveX. Everything works fine until I try to
> start Excel from the desktop after running my LV
> application. Then I get an "Exception access
> violation" generated by excel.exe. It seems like
> my application does not manage to end the
> excel.exe process which leads to the "violation
> error" next time Excel is to be opened. To quit
> Excel I call the "quit" method in
> Excel_Application and then call the "Automation
> Close".
0 Kudos
Message 3 of 5
(3,263 Views)
Is it possible to run an EXCEL macro using ActiveX?

Kevin

wrote in message
news:7rim1h$dnc$1@nnrp1.deja.com...
> Hallo,
>
> I am having a problem using ActiveX and Excel. I
> am using NT 4.0, Service Pack 3, Excel 97, Service
> Release SR1 and LabVIEW 5.1.
>
> My LV application opens an Excel worksheet,
> operates on the sheet and then closes it by using
> ActiveX. Everything works fine until I try to
> start Excel from the desktop after running my LV
> application. Then I get an "Exception access
> violation" generated by excel.exe. It seems like
> my application does not manage to end the
> excel.exe process which leads to the "violation
> error" next time Excel is to be opened. To quit
> Excel I call the "quit" method in
> Excel_Applic
ation and then call the "Automation
> Close".
>
> Anyone knows how to solve this?
>
> \Helena Dimitriou
>
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
0 Kudos
Message 4 of 5
(3,263 Views)
Greg, this is the problem: Granted that Excel closes properly when users try to close all opened refnums, when this VI is used as subvi (loop) "Excel.exe" does not close (every instance opened). It stays in the Task Manager until the program that uses this subVI ends. This is not good because "Excel.exe" uses a large memory.Just think what will happen if I try to use this "Excel" subVI a couple of hundred times in an application VI. It leaves at least 6000kb of memory for every instance multiply it by a couple of hundreds, then your PC crashes.

Another, open only one instance, the "Excel.exe" process remain in the Task Manager.

What can you say? You haven't tried?

Try this: create a vi which will open the Excel Application (wire the "open new instance
" terminal to TRUE), open an existing Excel workbook, add sheet, write numbers 1 to 255 from A1 to A255 and B1 to B255 to the added and close the ranges where the numbers are written, close the added sheet, close the opened workbook and close the Excel application. Then use this vi in a loop that iterates 500 times so that 500 sheets (plus three as default to Excel) will be added to the opened workbook. Before running the VI with the loop, open your Task Manager>>Processes. Run the VI and monitor how many "Excel.exe" while the loop is running and the memory usage it consumes. And take note of the "Excel.exe" which will remain in the Task Manager after the vi with loops ends. Then e-mail me (hydrocoolic_acidic_blood@yahoo.com OR jack@kornfreak.com) of things that went wrong and how to solve the problems that causes for things to go wrong.

Of course you can also send your VI.

This my main problem.
0 Kudos
Message 5 of 5
(3,263 Views)