I have a password protected workbook and would like to unlock it with activeX. How would one enter the password for a protected workbook problematically if excel is waiting for that password and not allow the vi to continue??
Solved! Go to Solution.
I have a same problem which I still couldn't figure out why the program still waiting for user to key-in password manually instead of it automatically get the password from my vi.
I attached together my VI snippet for you reference.
Firstly, the VI run and check whether the file exist or not.
If not, it will create the file and protect it using password "123". Then the program close. So now the excel is protected with password of 123.
Then I run the program again, and now since the file is already existed, the program will proceed to open the password protected file. But when it try to open the excel file, it stuck at waiting password from user. Is there anyway to make this password 'unprotect' process pragmatically in LabVIEW?
I've tried to use invoke node as suggested by aputman, but maybe i'm doing it wrongly. Can anyone correct me?
I think you are using the wrong VI to open the file. You are using the "Create Report" for a file that already exists, is there an "Open Report" VI you can use. Sorry I do not use the Report Generation Toolkit.
@Bob_Schor will hopefully chime it, as he is an expert in this field.
I used the Worksheet -> Unprotect method and you are using Workbook -> Unprotect. These are two separate actions, so make sure you are using the proper one.
Yes, I'm aware of this and did try out using workbook node to unprotect the excel workbook, but it seems that is not the one.
I did some digging and find out that the password '123' that I set in "Save Report to File.vi" below....
is actually go to a reference of Excel._Workbooks and not Excel._Workbook. However, when I retrieve the ActiveX reference using "Excel Get ActiveX Reference.vi" as below...
It return a reference of Excel._Workbook, not Excel._Workbooks. This is why it does not work when we try to unprotect it because it is a wrong reference!
I figured this out when reading the ActiveX documentation here = https://docs.microsoft.com/en-us/office/vba/api/excel.workbooks.open
As you can see, Workbooks.Open method takes an argument that consist of password, thus in LabVIEW, the invoke node will looks like this:
So my question now, is there any vi in the report generation that can return the ref to Excel._Workbooks so that I can use the ActiveX open method to unprotect the excel file by filling up the password argument (as indicated in picture above).
I can't unbundle the report in or report out wire since it is not allowed to unbundle the class in my vi.
So I'm stuck at the moment.
Hope someone can help.
Are you sure that is the password that you want to use? You want to prevent the file from being opened entirely without the password? In Excel 2010, this is equivalent to File -> Save As and clicking the Tools button -> General Options and setting the Password to open.
If this is what you want, the Excel Get ActiveX References returns an Application reference. Use this with a property node to get the Workbooks object.