Hugh Wilkinson wrote:

Thanks to the respondent to my original message.  The suggested code does not seem to 
match my Macro code.  Please be aware I am a novice at this.  Could that respondent show 
me the changes needed to the following Macro which was recorded by the 'Record Macro' 
function.  Am particularly interested in the Doc.Sheets.getByName ("whatever") 
format as I find the NR followed by relative sheet number makes changes in sheet location 
difficult.

REM  *****  BASIC  *****

sub ClearSummaryRow
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Protect"
args1(0).Value = false

dispatcher.executeDispatch(document, ".uno:Protect", "", 0, args1())

rem ----------------------------------------------------------------------
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "ToPoint"
args2(0).Value = "$B$6"

dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args2())

rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "Flags"
args3(0).Value = "R"

dispatcher.executeDispatch(document, ".uno:DeleteCell", "", 0, args3())

rem ----------------------------------------------------------------------
dim args4(0) as new com.sun.star.beans.PropertyValue
args4(0).Name = "Sel"
args4(0).Value = false

dispatcher.executeDispatch(document, ".uno:GoToStart", "", 0, args4())

rem ----------------------------------------------------------------------
dim args5(0) as new com.sun.star.beans.PropertyValue
args5(0).Name = "Protect"
args5(0).Value = true

dispatcher.executeDispatch(document, ".uno:Protect", "", 0, args5())


end sub


Hugh G Wilkinson
73 A  Frankleigh Street
Spreydon, CHCH 8002
Ph:  03 332 0546   Email:  [EMAIL PROTECTED]
Mobile:  027 450 8315
This macro works on the currently active sheet
1. Unprotect the sheet
2.  Remove Row 6
3. Protect the sheet again.

Although I understand what your recorded macro does, I am not certain what you want it to do. Did you not want to use the current sheet, or did you not want to delete the sixth row?

You can obtain a specific sheet using
oSheet = ThisComponent.getSheets().getByName("Sheet2")

You can protect and unprotect a sheet using
oSheet.protect("password")
oSheet.unprotect("password")

So, you should be able to use code similar to this

Sub RemoveEntireRow()
 Dim oSheet
 Dim iRow As Long
 Dim iDelCount As Long

 REM Use Sheet2
 oSheet = ThisComponent.getSheets().getByName("Sheet2")

 REM Delete 1 row
 iDelCount = 1

 REM Delete row six. Remember that using the API you start counting
 REM from zero, not one, so that is 0, 1, 2, 3, 4, 5. The GUI, on the
 REM other hand counts from 1, as in 1, 2, 3, 4, 5, 6.
 iRow = 5

 'oSheet.unprotect("")
 oSheet.getRows().removeByIndex(iRow, iDelCount)
 'oSheet.protect("")
End Sub

--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
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]

Reply via email to