LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Bring Excel 2007 to the front when called from LabView v9 in Windows 7

Solved!
Go to solution

I am building a duplicate system using Windows 7, LabView v9 and Excel v2007.  The original system used WinXP, Excel 2007 and LabView v8.6.  The issue is that the original system was able to bring Excel to the front when called from Labview using the property node -application-> visible.  This new configuration runs Excel, loads the data, runs the macros but does not bring Excel to the front.  The icon blinks in the Win7 taskbar and when selected displays over LabView.  If I minimize the Labview window, Excel is there.  This leads me to conclude that Excel is visible, as requested but will not come to the front until selected from the taskbar.  The only differences, besides the versions, is the original system template files used the .xls extension in and was run in Excel in compatible mode.  At the customers request, the new system uses the .xlsm extension on the Excel template files.  I have tried using application.visible = True in the macro as well.  Could be a setting in Labview?  Could be a setting in Excel? Could be .xls vs. .xlsm? Or an issue with Windows 7 and the newer version of Labview. 

 

HP workstation - Labview v9 - Windows 7 - Excel 2007 sp2

 

Thank you in advance

Stephen

0 Kudos
Message 1 of 11
(4,746 Views)

This is how you do it.You may not need the WindoState property depending on what you need to do.

 

Example_VI_BD.png

Tim
GHSP
0 Kudos
Message 2 of 11
(4,737 Views)
Thank you for your reply.  The diagram shown is what is in the original and works for XP - LV8.6-Excel2007.  When this code was installed on the new system with Win7-LV9-Excel2007 it did not work, Excel was launched, the macros run, the tables filled in but it remained behind LV and was not brought to the front.  The blinking icon in the task bar has to be selected before Excel come to the foreground.  It is as if the visible property no longer works or is ignored or is overridden.
0 Kudos
Message 3 of 11
(4,719 Views)
Is your Labview Front panel Modal? That could be your problem.
Tim
GHSP
0 Kudos
Message 4 of 11
(4,715 Views)
The vi property for window appearance->window behavior is set to default.  Presume from the help description that this is neither modal nor floating, at least not modal. 
0 Kudos
Message 5 of 11
(4,703 Views)

I had the same problem when using Excel 2007 and Windows 7 and still don't know what causes it.

I just used a few property nodes to set the window as maximised then minimised and then normal and visible as a workaround that ends up showing excel maximised for me.

Would be nice to know what causes that behavior and if there is a "correct" way to handle it.

0 Kudos
Message 6 of 11
(4,673 Views)
Another option is to use the Windows API to bring the window to the front. Should still work with Windows 7, but I don't know for sure since I have yet to try them under Windows 7.
0 Kudos
Message 7 of 11
(4,666 Views)

I will try the windowstate change.  Were these done in succession? (i.e. property node -> property node -> property node) Or were they done along the way such as call the ActiveX open and a property node then in a worksheet modification area etc. so there was some time between calls? 

 

I am not sure about the API since the discussion there is with regard to DDE.  (Taken from the link document:  If you want to call a DLL that contains ActiveX objects, use the Automation Open VI with the Property Node and the Invoke Node.).  I am calling Excel as an application not as a library call unless I am mistaken, which I could certainly be.  Are you thinking that once Excel is active through the Automation Open VI that a DLL call to set the application visible would work?  I may be trying this already but in Excel through the use of the macro I call from LabView.  It contains application.visible = True at the beginning before reading files and plotting data.  

 

I may try sprinkling Property node with application->visible in various locations in the LabView diagram as I do update cells after the call to the plot macro.  The puzzle for me is the blinking Excel icon in the task bar.  This means active and running but not visible or something wrong as well.  There are a few #VALUE cells if not all test in the system are run.  Again not a problem in Excel 2007-WinXP-LV8.6

 

Thank you again one and all.

0 Kudos
Message 8 of 11
(4,649 Views)

sfm-dss wrote: 

I am not sure about the API since the discussion there is with regard to DDE.  (Taken from the link document:  If you want to call a DLL that contains ActiveX objects, use the Automation Open VI with the Property Node and the Invoke Node.).  I am calling Excel as an application not as a library call unless I am mistaken, which I could certainly be.  Are you thinking that once Excel is active through the Automation Open VI that a DLL call to set the application visible would work?  I may be trying this already but in Excel through the use of the macro I call from LabView.  It contains application.visible = True at the beginning before reading files and plotting data.  


Are you referring to the comment I made regarding the link to the Windows API functions? Those have nothing to do with DDE. They call Windows API functions. Like FindWindow and SetWindowPos. These work for any window. You could call these after you've opened Excel and force the window to the top.

Message 9 of 11
(4,633 Views)
Solution
Accepted by topic author sfm-dss

sfm-dss wrote:

I will try the windowstate change.  Were these done in succession? (i.e. property node -> property node -> property node) Or were they done along the way such as call the ActiveX open and a property node then in a worksheet modification area etc. so there was some time between calls? 


 visible.png

I just used something like this in any place where i would normally just make excel visible. Works for me on Win7 x64 even though i'm not really sure why.

On WinXp i never had any problems with just using the visible property with a single windowstate change or even without one.

Message 10 of 11
(4,610 Views)