LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to write to a password protected excel sheet using ActiveX?

Hi all,
I would like to write to a protected Excel sheet. I protect the sheet just in case the data is not wrongly programmatically saved to other cells. These cells contained formulas.

Please help.

Thanks,
keng
0 Kudos
Message 1 of 4
(4,604 Views)
Keng,

The Workbooks.Open method has an option input for a password. You would need open the spreadsheet in this fashion to do what you want if you have password protected the file as well.. There are also a _Workbooks.Protect and _Workbooks.Unprotect methods to do what you need in the middle of the application.

Randy Hoskin
Applications Eningeer
National Instruments
http://www.ni.com/ask
0 Kudos
Message 2 of 4
(4,604 Views)
Hi Randy,

Thank you for looking into my problem.

I have looked into the Workbook.open property node. There is "password" on the property node. Please see attached diagrams.
Is is the right way to do it?
Please advise further.

For your information, the Excel workbook and sheet 1 are password protected.

Thanks,
keng
Download All
0 Kudos
Message 3 of 4
(4,604 Views)
keng,

Make sure that you close all the references to Excel (Application in first piture is not closed and _Workbooks in second). Each refnum wire needs to end either in an indicator if it is going to be a sub VI, or an Automation close if the VI is not a subVI as yours are in your examples.

To unprotect your sheets, you will also probably need to use the Unprotect method as I talked about earlier.

Randy Hoskin
Applications Engineer
National Instruments
http://www.ni.com/ask
0 Kudos
Message 4 of 4
(4,604 Views)