Skip to content

Instantly share code, notes, and snippets.

@chanwit
Created December 17, 2010 03:51
Show Gist options
  • Select an option

  • Save chanwit/744459 to your computer and use it in GitHub Desktop.

Select an option

Save chanwit/744459 to your computer and use it in GitHub Desktop.
OpenOffice Macro to help scoring
REM ***** BASIC *****
sub Main
dim std_id as String
dim std_score as String
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")
dim args1(0) as new com.sun.star.beans.PropertyValue
dim args2(17) as new com.sun.star.beans.PropertyValue
dim cell as Object
dim c_row as Variant
dim args3(0) as new com.sun.star.beans.PropertyValue
do while true
std_id = InputBox( "Enter ID:" )
if std_id = 0 then exit sub
if std_id = "" then exit sub
rem ----------------------------------------------------------------------
args1(0).Name = "Sel"
args1(0).Value = false
dispatcher.executeDispatch(document, ".uno:GoToStart", "", 0, args1())
rem ----------------------------------------------------------------------
args2(0).Name = "SearchItem.StyleFamily"
args2(0).Value = 2
args2(1).Name = "SearchItem.CellType"
args2(1).Value = 0
args2(2).Name = "SearchItem.RowDirection"
args2(2).Value = true
args2(3).Name = "SearchItem.AllTables"
args2(3).Value = false
args2(4).Name = "SearchItem.Backward"
args2(4).Value = false
args2(5).Name = "SearchItem.Pattern"
args2(5).Value = false
args2(6).Name = "SearchItem.Content"
args2(6).Value = false
args2(7).Name = "SearchItem.AsianOptions"
args2(7).Value = false
args2(8).Name = "SearchItem.AlgorithmType"
args2(8).Value = 0
args2(9).Name = "SearchItem.SearchFlags"
args2(9).Value = 65536
args2(10).Name = "SearchItem.SearchString"
args2(10).Value = std_id
args2(11).Name = "SearchItem.ReplaceString"
args2(11).Value = ""
args2(12).Name = "SearchItem.Locale"
args2(12).Value = 255
args2(13).Name = "SearchItem.ChangedChars"
args2(13).Value = 2
args2(14).Name = "SearchItem.DeletedChars"
args2(14).Value = 2
args2(15).Name = "SearchItem.InsertedChars"
args2(15).Value = 2
args2(16).Name = "SearchItem.TransliterateFlags"
args2(16).Value = 1280
args2(17).Name = "SearchItem.Command"
args2(17).Value = 0
dispatcher.executeDispatch(document, ".uno:ExecuteSearch", "", 0, args2())
rem ----------------------------------------------------------------------
cell = ThisComponent.getCurrentSelection()
c_row = cell.CellAddress.row
if(c_row) > 4 then
std_score = InputBox("Enter Score:")
args3(0).Name = "ToPoint"
args3(0).Value = "$N$" + (c_row + 1)
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args3())
cell = ThisComponent.getCurrentSelection()
cell.setValue(std_score)
end if
loop
end sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment