Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm trying to write in a worksheet using a macro, I have no problem, as long
the worksheet isn't protect. But I want to protect the file, so, the user wont be able to change anything.. can I get some help in this problem? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Fernando,
Below is some simple code that will work in any version. This is one approach to take. 1) Unprotect the sheet; 2) make your changes; 3) Protect the sheet. You don't say which version of Excel you will be using. The newer versions have additional features for the Protection command. Search the Excel Visual Basic Help for "Protect Method" for more details (UserInterfaceOnly may be of interest to you also). Troy Sub Test1() '''Unprotect the sheet. ActiveSheet.Unprotect '''Your code to make changes. ActiveSheet.Range("A1").Value = "Hello" '''... '''Protect the sheet. ActiveSheet.Protect End Sub "Fernando Duran" wrote in message . .. I'm trying to write in a worksheet using a macro, I have no problem, as long the worksheet isn't protect. But I want to protect the file, so, the user wont be able to change anything.. can I get some help in this problem? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Fernando,
Protect the workbook in a macro, like this: Sheets(MySheet).Protect UserInterfaceOnly:=True ' Password:="MyPass" ' Password optional. Or your macro can unprotect the sheet, make its changes, then protect it. -- Earl Kiosterud mvpearl omitthisword at verizon period net ------------------------------------------- "Fernando Duran" wrote in message . .. I'm trying to write in a worksheet using a macro, I have no problem, as long the worksheet isn't protect. But I want to protect the file, so, the user wont be able to change anything.. can I get some help in this problem? |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If I protect the worksheet with a macro, do you I have to unprotect it while
writing, right? "Earl Kiosterud" wrote in message ... Fernando, Protect the workbook in a macro, like this: Sheets(MySheet).Protect UserInterfaceOnly:=True ' Password:="MyPass" ' Password optional. Or your macro can unprotect the sheet, make its changes, then protect it. -- Earl Kiosterud mvpearl omitthisword at verizon period net ------------------------------------------- "Fernando Duran" wrote in message . .. I'm trying to write in a worksheet using a macro, I have no problem, as long the worksheet isn't protect. But I want to protect the file, so, the user wont be able to change anything.. can I get some help in this problem? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
protect cells in excel, but also allow a search in those cells? | Excel Worksheet Functions | |||
How do I protect cells or a range of cells in excel spreadsheet? | Excel Worksheet Functions | |||
Protect Only Certain Cells | Excel Discussion (Misc queries) | |||
Protect cells | Excel Worksheet Functions | |||
Protect cells | Excel Discussion (Misc queries) |