From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Probems with excel: open workbook and write file properly

Hi all,
actually I have some problems to control Excel via LabView:
- LabView tells me about unwired or bad terminals, and
- the files I already have written are not fully usable.

Let me describe, please:
1.) The VI "ExcelOpenWorkbook.vi" (see zipped attachment) has already been working on 2 different PCs, but in the old version "ExcelOpenWorkbook-old.vi". Since some days ago, LabView complains about "unwired or bad terminals" in function Invoke Node: Workbooks.open. But meanwhile I did not change this vi or the Excel installation on one of those PCs.
So the usual question: Yesterday it worked, but today it doesn't. Why this?
Therefore, I changed (with help of the Excel-VB Online Help) all the parameters to (at least any) values, most of them being the defaults. With no success yet.
So my first question: Can anybody please tell me what I'm doing wrong here and how to do better?

2.) At those good times when "ExcelOpenWorkbook.vi" still was working, I have generated some Excel files (*.xls) containing one or more spreadsheets with even the data in it that I expected to be there, see attached excel-datafile.xls.
I used (among others) the VI "ExcelWriteCells.vi", also attached.
But when I open one of them, the tool bar button "diagram wizzard" is greyed out. So I guess, this is a silent complaint of Excel regarding the contents of my file.
Therefore, I changed my program to use "ExcelWriteCells_Dbl.vi"  - but without success. Obviously, now I get numbers instead of strings into my data files, but still I'm not able to use the "diagram wizzard" button at all.
(There is a workaround: one can copy all the data, open a new worksheet, past them into, and then the diagram wizzard button is enabled. But probably it is really no good idea to write software that requires such post-processing 🙂 )
My second question: How would I have to control opening / writing / closing of Excel files to prevent such effects?

(For explanation: In the end, I want to / have to store 3D arrays into several worksheets within one Excel file. So, unfortunately, I cannot simply write text files, name them *.xls and have Excel read them as spreadsheets. At least I don't know how.)

Any help is greatly appreciated.

With regards,


Jost

0 Kudos
Message 1 of 4
(2,471 Views)
Hi,
now I found the solution for at least my first question (LabView Error: bad wires at "Workbooks.open"): See the 2 images attached.

ExcelOpenWorkbook-nok.jpg  shows the former contents fo this VI.  You find 13 parameters in the "open" function. You see the broken arrow in the upper left corner indicating "syntax" errors.
ExcelOpenWorkbook-ok.jpg  shows the new contents fo this VI.  You find two more = 15 parameters in the "open" function. You see that the complete arrow indicates a runnable VI.

I should say that both PCs are maintained by our IT group, so behind the surface there might happen updates that I will not be told about - and, more ugly: that I'm not able to control or to prevent.


Waht did I do?
- I removed the function call "Workbooks.open" completely,
- added it again - and at this moment it showed up with the 2 additional parameters.
- Then, of course, I had to re-wire it completely by hand. For one single ActiveX call this is done quickly, but imagine you have a large project with - say - 100 ActiveX calls in it. And sooner or later you will have 5, 10 or 20 projects that need this kind of maintenance. This is "trouble by design".


To all people intending to use ActiveX within LabView: BE WARNED.
As you can read everywhere in all the forums, you will have this kind of problems everytime when an (intended or unintended) update of whatever parts of Windows / Office occurs.

Unfortunately, due to my customer's demands, I'm more or less forced to use AxtiveX (except, anyone could suggest a better solution for storing 3D Arrays in a spreadsheet?)
But from now on I never would suggest anyone to use ActiveX if it is possible to avoid.


Nevertheless, my second question still is open: How can I write data to a spreadsheet in a way that allows me to use the diagram wizzard afterwards?
Any help still appreciated 🙂


with regards,

Jost

Download All
0 Kudos
Message 2 of 4
(2,466 Views)

Dear Jost

To be able to use the chart wizard in Excel you only need to uncheck the checkbox under menu "Tools:Share..." (in german "Extras: Arbeitsmappe freigeben..."). This must surely be possible programmatically using VB, too ...

Best regards

Philipp Roessler

 

0 Kudos
Message 3 of 4
(2,413 Views)

I'm glad to see thatyou got the first problem worked out. The second problem is not so easy as Philipp R says. Yes when you open the workbook you can take off the sharing and it will work however we need to figure out why it is being set to shared. I have a feeling that in the settings of the template (if you are using one) has been set to be shared and the settings are just being carried over to the new workbook. If I could see more of your code I could probably be of more help. just seeing what you are using to open the excel file is not enough, we need to be looking at how the file is being written and whether or not it is using a template.

If you are wanting to do some post analysis you can use the chart function and control it with labview. In the set of VI's that I posted to the excel board there is a VI in there that allows you to graph the intended rows and columns.

I hope I helped some.




Joe.
"NOTHING IS EVER EASY"
0 Kudos
Message 4 of 4
(2,404 Views)