Ask Your Question
0

Preventing BASIC crash unprotecting Calc sheets

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 close merge delete

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
Login/Signup to Answer

Question Tools

1 follower

Stats

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

Seen: 45 times

Last updated: Apr 16 '17