Jack Gillis wrote:
----- Original Message ----- From: "Andrew Douglas Pitonyak"
<[EMAIL PROTECTED]>
Newsgroups: gmane.comp.openoffice.questions
Sent: Thursday, November 03, 2005 10:49 PM
Subject: Re: Please Help With This Macro
Jack Gillis wrote:
I need help with this macro. Its purpose is to cycle through all
the sheets in the workbook, protect all the cells in the sheet,
protect the sheet and return to the original active cell.
I have put together part of the macro using the examples in Andrew
Pitonyak's macro documents as well as the OOo forums as a base.
Yeah, but I'll bet that you did not look at page 331 of my book :-)
Actually, all I have is your Getting Started With Macros and Useful
Macro Information For Open Office. I am about to remedy that as soon
as I click the send icon.
Is this close to what you want?
oRange =
ThisComponent.getSheets().getByIndex(0).getCellRangeByName("A1:C10")
oRange.CellProtection = com.sun.star.util.CellProtection.IsLocked
Sub ProtectAllSheets
Dim osheets as Object
Dim osheet as Object
osheet = thisComponent.sheets
for i = 0 to oSheet.count - 1
oOldSeletion = ThisComponent.CurrentSelection 'Store the Active Cell
osheet.getByIndex(i).unprotect("") 'unlock the sheet
'Now protect all the cells in this sheet
Here I can't figure out what statements are required to protect all
the cells in the sheet. Will someone 'please give me a clue. I've
searched Andrew Pitonyak's and the OOo Forums but have not been able
to 'find an answer.
Oh, so you want ALL of the cells? Well, then get the entire range, or
even better, simply do it on the sheet itself.
ThisComponent.getSheets().getByIndex(0)..CellProtection =
com.sun.star.util.CellProtection.IsLocked
Now that is a truly elegant solution.
I am off to order the book.
Thank you very much.
'Finished Protecting all the cells
oSheet.getByIndex(i).protect("") 'lock the sheet
ThisComponent.CurrentController.Select(oOldSelection) 'Return to
the starting cell of this sheet
next
End Sub
It would also help if in addition to the missing code above, Someone
could tell me how to get the name of the current active sheet. That
is for another project.
Page 369 to 373 of my book. On page 372, you find the
getActiveSheet() method.
ThisComponent.getCurrentController().getActiveSheet().getName()
Thank you very much.
Your welcome, and glad that it helped... Remember that if you get the
book, you can then download the PDF version :-)
--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.sxw
My Book: http://www.hentzenwerke.com/catalog/oome.htm
Info: http://www.pitonyak.org/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index.html
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]