PDA

View Full Version : read write access using VBA



Jacob Edison
09-03-2010, 01:24 PM
Hi all,

Is there a code we can write so that when i cklick a button the excel has only read-only access and by clicking another button, it gets both read and write access? :confused:

Regards
Jacob

Ken Puls
09-03-2010, 10:55 PM
Ummm... maybe. It depends on how you're trying to go about this.

If you want true read only access at the file level, you can set the properties of the Excel workbook to Read Only at the operating system level. You'd then need a windows API call to flip it to Read/Write. As I recall, though, you can't save the file using the same name as the file you opened as read only though, so saving an update could be tricky.

If you're just trying to prevent users from modifying the data in the file though, worksheet protection is going to be a LOT easier to implement...

If you give us a bit more idea of your ultimate objective, we could pursue the better of the options with you.