We will be migrating from Ask to Discourse on the first week of August, read the details here

Ask Your Question
0

Preventing BASIC crash unprotecting Calc sheets [closed]

asked 2017-04-16 14:09:32 +0200

JET gravatar image

How can I prevent the Illegal Argument Exception crash when BASIC attempts to unprotect a sheet using no (null) password? On error does nothing & the macro crashes. I want to use this automate some functions in Calc & skip properly protected sheets.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2020-09-29 22:24:11.291974

1 Answer

Sort by » oldest newest most voted
0

answered 2017-04-16 14:45:22 +0200

karolus gravatar image

Hallo

Here is an Example for python

from com.sun.star.lang import IllegalArgumentException

def sheet_unprotect_test():
    doc = XSCRIPTCONTEXT.getDocument()
    sheets = doc.Sheets
    for sheet in sheets:
        try:
            sheet.unprotect('')
        except IllegalArgumentException:
            continue
        # do other stuff
        sheet.protect('')
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-04-16 14:09:32 +0200

Seen: 74 times

Last updated: Apr 16 '17