Can macros be used on protected sheets?

Discuss the spreadsheet application

Can macros be used on protected sheets?

Postby Sophorus » Fri Jan 25, 2008 9:33 pm

I have created a drill sheet for simple arithmetic operations. The sheet is intended to check the answers when a button is pushed (clicked) and to reset the entire sheet to a new set of problems when another button is pushed. To achieve this I inserted to buttons and linked each of them to a recorded macro. It worked fine, but only when the sheet is not protected. When I activate the sheet protection (to prevent accidental change to the formulas) a pop-up dialogue informs me that protected cells cannot be modified.

Is there a way I can reset the exercise (which means erasing the typed in answers, hide the check, and replace numbers with randomly generated new ones) using a button operated macro and have the macro operate on protected cells?

Thanks for any help,

Posts: 1
Joined: Fri Jan 25, 2008 8:18 pm

Re: Can macros be used on protected sheets?

Postby Villeroy » Fri Jan 25, 2008 9:51 pm

This question belongs to viewforum.php?f=20.
Code: Select all   Expand viewCollapse view
oSh = thisComponent.Sheets.getByName("bla") 'by name
REM oSh = thisComponent.Sheets.getByIndex(0) ' sheet #1 by position
sPWD = "" 'password if any
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.4
User avatar
Posts: 28851
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Can macros be used on protected sheets?

Postby kingfisher » Sat Jan 26, 2008 12:07 am

Is it not possibly simply to unprotect the cells you wish to edit? Protection is at two levels. The first level is the cell level where the default style is set to cell protection. Protecting the sheet merely switches on the cell protection.

You have these options
# Use Menu: Format >Cells >Cell Protection to remove cell protection from certain cells
# Change the default style (F11) to remove cell protection from the default style and set protection for certain cells using the Format command
# Create a new style (F11) with or without cell protection depending on how you configure the Default style.
Apache OpenOffice 4.1.6 on PCLinuxOS
User avatar
Posts: 2120
Joined: Tue Nov 20, 2007 10:53 am

Return to Calc

Who is online

Users browsing this forum: No registered users and 36 guests