LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to protect other VI to open workbook which is already open and being used by another VI ?

We have to different VIs, but both needs to access a same excel workbook. I would like to protect one VI to access a specified workbook when it is being used by second VI. I mean,  untill one VI finish it works with a specified workbook, the another VI should not be able to access(not even read) it. How can I do it ?
 
regards
Pranav
0 Kudos
Message 1 of 7
(3,407 Views)
Under Advanced->Syncronisation you find the semaphore palette.

Other possibilities are to use Action Engines and the like.

There also might be an Excel-based solution of protecting the workbooks.

Felix
Message 2 of 7
(3,397 Views)
Hello,
Thanks for reply. Please correct text of my question. It is "how to prevent one VI from accessing a specified workbook which has already been opned and being used by another VI ?"
 
As you suggested the use of semaphore, but can i use it as both VIs are different and running in parellal ? This is because,  labview help states that semaphore can not be used to communicate between labview application instances.
 
What are Action engines ?
 
I was thinking to use "Deny Access" function available in FILE I/O palette. However I could not generate refnum for the workbook which is already open. To open this workbook in one of above VIs, i used open excel VI>>> open new book VI>>>  workbook Method "save as" to rename it. However I am not sure whether "Deny access" can be used to solve my problem.
 
Regards
Pranav
0 Kudos
Message 3 of 7
(3,378 Views)

Hi,

Could you create a filename by programmatically (Date and time) or something so each one is unique and write this path to a Global.  Then both vi's will be able to read this global, get a refnum on the same workbook whereby you could then use the "Deny Access" function you mentioned?

Craig

LabVIEW 2012
0 Kudos
Message 4 of 7
(3,371 Views)

Hello  Craigc,

I did not get, what you said. File name is given by user of his/her own choice and depends upon some factors. I am also not clear about global variable. would it work for two entirely different VIs ?  Even about Deny access, I am not sure whether it is the right fucntion to the job,  I am still exploring.

regards

Pranav

 

0 Kudos
Message 5 of 7
(3,348 Views)
Hello Craig
 
As you suggested, now I am clear about the use of global variable. But still I am not able to generate refnum for the workbook which is already opened by one VI. For this, I have attached one JPG file for you, in which i have copied and pasted the required componenets which are used in above VI. What I would like to do is to generate refnum for the workbook which is opened and saved by "save file as" control. This is because "deny access" needs refnum of this workbook.
 
thanks and regards
Pranav
0 Kudos
Message 6 of 7
(3,327 Views)

The suggestion by Felix to use an Action Engine is very good.

See this Nugget were I talk about Action Engines.

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 7 of 7
(3,319 Views)