From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, 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: 

error 1 occured in sub VI

Solved!
Go to solution

Hello

I get error 1 occured in the sub VI '' get sheet data" which states that an input parameter is invalid,

The VI where is the error, reads data from excel file, following the selected sheet. Please see the attached VI. 

I wired String Invoke node of Select sheet to sheets name and I used global variables of refnum wired to the invoke nodes.

These global variables of refnums and of " sheets name " are the outputs of the sub VI that allows to get the sheet names.

The problem is that when i run the main VI, it stops because of this error.

Is that because of refnums used in global variables ? Because even when I used them as controls, I found the same error, please help, I've been stucked here for a long time and I can not move forward as I can not get the data.

 

I thank you.

 

 

0 Kudos
Message 1 of 12
(2,635 Views)

Hi Student,

 

Is that because of refnums used in global variables ?

Who knows?

You didn't mention which function throws the error!

 

Because even when I used them as controls, I found the same error,

So it's not the fact you used globals or controls, but most probably the problem comes from the values stored in those globals/controls.

Did you check them?

 

please help, I've been stucked here for a long time and I can not move forward as I can not get the data.

Debug your VI. Find the cause of the error. Remove that cause…

(Generic answer because of your generic question.)

 

Btw. the inner case structure is RubeGoldberg: replace it with a NOT!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 12
(2,629 Views)

hello

Thank you for your reply

I debug the VI, the error occured at the output of " item " of the first invoke node of " sheets". I know the function that throws the error but I didn't understand the cause behind this and how to remove it?

Please How can I check the values stored in refnums? 

 

0 Kudos
Message 3 of 12
(2,619 Views)

Hi Student,

 

the error occured at the output of " item " of the first invoke node of " sheets".

There is a race condition with "select a sheet" as the terminal probably is read before the items ("strings") are set…

 

How can I check the values stored in refnums? 

Debug the routines which initialize those refnums to check they are working correctly.

Check for non-existance of race conditions when calling your subVI: are the globals written before you read them in the VI.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 12
(2,613 Views)

Hello!

 

I checked, I don't think there is a race condition with "select a sheet", the items are set and then stored in the list box, to verify this i add a boolean led,  the " select a sheet " is read after "strings" are set.

For refnums global variables,you think I should put them in the main VI to avoid race condition ? 

 

Thank you.

 

0 Kudos
Message 5 of 12
(2,579 Views)

Hi Student,

 

I don't think there is a race condition with "select a sheet", the items are set and then stored in the list box, to verify this i add a boolean led,  the " select a sheet " is read after "strings" are set.

Setting that combobox items is done in parallel to reading the current ring value in your VI, so there is a race condition!

To be sure there is no race condition you have to create a data dependency:

 check.png

Even then it's kind of senseless to set the combobox items as the user has no chance to select any of the items. Why don't you supply a sheet name (as scalar string) to your subVI?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 12
(2,577 Views)

Thank you for your reply,

 

I created a data dependency as shown in the example you gave me, still have always the same error code "1"

When I supply a sheet name to the sub vi , I get error code 3008 " The automation type interface for the specified class can not be obtained. Check if the type of refnum automation is of the correct class for this operation. in get sheet data.vi-> main VI.vi", and then in the main VI, how to wire the listbox "select a sheet" to the sub VI if the sub vi is feeded by a scalar string ( in the main, the user have to choose one item = sheet name from the list) 

 

0 Kudos
Message 7 of 12
(2,572 Views)

Hi Student,

 

When I supply a sheet name to the sub vi , I get error code 3008 " The automation type interface for the specified class can not be obtained. Check if the type of refnum automation is of the correct class for this operation. in get sheet data.vi-> main VI.vi",

Why don't you create a single test VI where you just try to build a working ActiveX communication with Excel? (Step by step: when one step is working you integrate the next one.)

Why additionally create race conditions, handling globals and so on?

 

in the main VI, how to wire the listbox "select a sheet" to the sub VI if the sub vi is feeded by a scalar string ( in the main, the user have to choose one item = sheet name from the list) 

The combobox gives you a scalar string when you read its terminal: just wire this to your subVI…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 12
(2,569 Views)

Hi GerdW,

 

I created a single test VI many times, and I debugged step by step, it works well but it's weird, because when calling the sub vi in the main, each time, the error occured just at the begining of runing of the vi" !!

 

 

"The combobox gives you a scalar string when you read its terminal: just wire this to your subVI…"

This is what I did in the begining, as in the vi I attached + an invoke node to feed the list box with sheets name. that doesn't work, May be the race condition happened because the listbox is not fed with "sheet names" in the appropriate VI.!! although, In the main, I wired the output "sheet names" of the sub vi "get sheets names" to the invoke node "strings" of "select a sheet" 

 

 

0 Kudos
Message 9 of 12
(2,567 Views)

Hi!
you will find below a capture from the main VI, where there are 2 sub vi, 1) " get sheets" which outputed a string array of sheets name of an xls file, and 2) " get data" which gives the array of data in each sheet. I wired "string" invoke node to the terminal of " sheets name" to feed the combobox with these values, but the issue is that there is a race condition : "select a sheet" is read before that values are written via the invoke node, so there isn't value entred to the sub vi and that's why i could not get the " sheet data " array!
Please, what shall I do to write the strings first and then read the values in " select a sheet" ?
Thank you for your help

race condition.PNG

0 Kudos
Message 10 of 12
(2,547 Views)