OpenOffice.org is working on correcting the en-GB localisation of that documentation website page.
Regards,
Jerome K Maule McKean
Ian Laurenson <[EMAIL PROTECTED]> wrote:
On Fri, 2005-03-11 at 09:27, G. Roderick Singleton wrote:
On Wed, 2005-03-09 at 15:30 -0700, Jeanie Hahn wrote:
> Hi, I hope I am sending this to the right place.
> > I have a macro I used in Microsoft excel to highlight duplicates and
> promote the duplicates to the top of the file.
> > I am hoping that someone out there can help me convert this macro so
> that I can use it in staroffice.
> > I have attached the macro.
> > Thanks,
> Jeanie
> plain text document attachment (macro2.txt)
> Sub HighlightDupTickets()
> >
Please see if http://documentation.openoffice.org/HOW_TO/ and the VBA docs help.
Using the doc that Ger refers to (bottom of the page) here is the converted macro:
Sub HighlightDupTickets() ' Highlight Duplicate Ticket Numbers ' by TCRMA-Solid Waste Kenny Perryman 'Converted for Calc by Ian Laurenson (Iannz)
'Macro Purpose ' Starting in row 2 searches for duplicates entries in column J ' Moves the first duplicate of a duplicate pair to row 2 ' Colours all duplicate rows yellow
' This macro assumes the data is sorted on Column J
' I think that rows and columns in Excel are 1 based ' whereas in Calc they are zero based.
Dim celly As Integer ' Declares variable
oController = ThisComponent.CurrentController
'These vraiables needed for the UNO dispatch calls for copy and paste
oFrame = oController.Frame
oDispatcher = createUnoService("com.sun.star.frame.DispatchHelper")ws = oController.ActiveSheet ' sets active sheet to ws so you dont have
to type activesheet over and over
celly = 2 ' initializes variable
' loops. stops on empty cell While len(ws.getCellbyPosition(9, celly).string) > 0
'looks for cells that match If ws.getCellbyPosition(9, celly).String = _
ws.getCellbyPosition(9, celly + 1).String Then 'The next row (which is a duplicate) is coloured yellow
ws.Rows(celly + 1).CellBackColor = 16776960 'Cut the first row of the duplicate pair and insert it at row 2
oController.select(ws.Rows(celly))
oDispatcher.executeDispatch(oFrame, ".uno:Cut", "", 0, Array())
ws.Rows.RemoveByIndex(celly, 1)
ws.Rows.InsertByIndex(1, 1)
oController.select(ws.Rows(1))
oDispatcher.executeDispatch(oFrame, ".uno:Paste", "", 0, Array())
'Set the cut and pasted row to yellow as well
ws.Rows(1).CellBackColor = 16776960 End If
celly = celly + 1 ' change cell referance to next cell
Wend ' end of loop. used with while
End Sub
