| VBA Code Pattern |
OpenOffice Basic Format |
| Sub Pulsante41_Clic()
Dim balue
ActiveSheet.PrintOut
ActiveSheet.PrintOut
balue = Worksheets("DATI").Cells(2, 14)
Worksheets("DATI").Cells(2, 14) = Worksheets("DATI").Cells(2, 14) + 1
Worksheets("FATTURA").Cells(2, 5) = Date
ActiveWorkbook.SaveCopyAs "C:\FATTURE\FAT_" + Mid(Date, 7, 10) + Mid(Date, 4, 2) + Mid(Date, 1, 2) + "_" + CStr(balue) + ".XLS"
Worksheets("FATTURA").Range("E2").Formula = "=Today()"
End Sub
| Sub Pulsante41_Clic()
Dim balue as integer
rem ThisComponent.CurrentController.ActiveSheet.PrintOut
rem ThisComponent.CurrentController.ActiveSheet.PrintOut
balue = ThisComponent.Sheets.getByName()("DATI").Cells(2, 14)
ThisComponent.Sheets.getByName()("DATI").Cells(2, 14) = ThisComponent.Sheets.getByName()("DATI").Cells(2, 14) + 1
ThisComponent.Sheets.getByName()("FATTURA").Cells(2, 5) = Date
ThisComponent.SaveCopyAs "C:\FATTURE\FAT_" + Mid(Date, 7, 10) + Mid(Date, 4, 2) + Mid(Date, 1, 2) + "_" + CStr(balue) + ".XLS"
ThisComponent.Sheets.getByName()("FATTURA").Dim oSheet as Object
oSheet = ThisComponent.CurrentController.ActiveSheet
oSheet.getCellRangeByName($1)("E2").Formula = "=Today()"
End Sub
|
| Sub WR_Nxt()
WR_TxtBx.Value = WR_TxtBx.Value + 1
End Sub | Sub WR_Nxt()
WR_TxtBx.Text = Int(WR_TxtBx.Text) + 1
End Sub |
| Application.Wait (Now() + TimeValue("00:00:0.*?")) | wait |1|100 |
| Workbooks.Open (ActiveWorkbook.Path & "\.*?") | Dim DirectoryName as String Dim NoArgs() NewWorkbook = StarDesktop.loadComponentFromURL ("file:///" & DirectoryName & ""/$1"", ""_blank"",0 ,NoArgs() ) |
| .*? = WorksheetFunctions.Average(Range.*?) | FuncService = createunoservice("com.sun.star.sheet.FunctionAccess") oSheet = ThisComponent.CurrentController.ActiveSheet $1 = FuncService.callFunction(""AVERAGE"",array(oSheet.getCellRangeByName(""$2""))) |
| Worksheets.Add before:= Worksheets(.*?) | Dim oSheet as object oSheets.InsertNewByName( "?1?", findSheetIndex($1)) |
| val = Activesheet.Cells(row,col).Value | oSht = ThisComponent.CurrentController.ActiveSheet
val = oSht.getCellByPosition(col,row).formula
|
| Worksheets.Add after:= Worksheets(.*?) | Dim oSheet as object oSheets.InsertNewByName( "?1?", findSheetIndex($1) + 1) |
| Worksheets.Add before:=ActiveSheet | Dim oSheet as object oSheet = ThisComponent.CurrentController.ActiveSheet ThisComponent.Sheets.InsertNewByName( "$1", findSheetIndex(oSheet.Name) ) |
| Application.ScreenUpdating = False | ThisComponent.LockControllers |
| Sub Worksheet_Activate().*?End Sub | Global oActiveSheetListener as Object Global CurrentWorksheetName as String Sub WorksheetActivationListenerOn CurrentWorksheetName = ""
oActiveSheetListener = createUnoListener(""ACTIVESHEET_"", ""com.sun.star.beans.XPropertyChangeListener"") ThisComponent.CurrentController.addPropertyChangeListener(""ActiveSheet"", oActiveSheetListener)$1
End Sub Sub WorksheetActivationListenerOff ThisComponent.CurrentController. removePropertyChangeListener(""ActiveSheet"", oActiveSheetListener) End Sub |
| Application.ScreenUpdating = False | ThisComponent.LockControllers |
| Application.ScreenUpdating = False | ThisComponent.LockControllers |
| Application.ScreenUpdating = True | ThisComponent.UnlockControllers |
| Worksheets.Add after:=ActiveSheet | Dim oSheet as object oSheet = ThisComponent.CurrentController.ActiveSheet ThisComponent.Sheets.InsertNewByName( "$1", findSheetIndex(oSheet.Name)$1) |
| Application.ScreenUpdating = True | ThisComponent.UnlockControllers |
| Application.ScreenUpdating = True | ThisComponent.UnlockControllers |
| Private Sub Worksheet_Activate() | Sub Worksheet_Activate() |
| Range(.*?).Offset(.*?,.*?).Value | ThisComponent.CurrentController.ActiveSheet.getCellRangeByName($1).getCellByPosition($2,$3).Value |
| Range(.*?).Cells(.*?,.*?).Value | ThisComponent.CurrentController.ActiveSheet.getCellRangeByName($1).getCellByPosition($2,$3).Value |
| ActiveSheet.Charts(.*?).Delete | ThisComponent.CurrentController.ActiveSheet.getCharts().removeByName($1) |
| .*?.RunAutoMacros xlAutoOpen | Dim DirectoryName as String Dim NewWorkbook as Object Dim Args(0) as new com.sun.star.beans.PropertyValue Args(0).Name = "MacroExecutionMode" Args(0).Value = com.sun.star.document.MacroExecMode.ALWAYS_EXECUTE NewWorkbook = StarDesktop.loadComponentFromURL (""file:///"" & DirectoryName & ""/$1"", ""_blank"",0 ,Args() ) |
| .*? = ActiveWorkbook.Path | Dim URLStr as String Dim $1 as String GlobalScope.BasicLibraries.LoadLibrary("Tools") URLStr = ThisComponent.getURL() $1 = DirectoryNameoutofPath(URLStr, ""/"") |
| Selection.end(.*?).Select | Dim oSheet as Object oSheet = ThisComponent.CurrentController.ActiveSheet ThisComponent.CurrentController.select(MoveCursorToEnd(ThisComponent.getCurrentSelection,"$1")) |
| .*? = ActiveWorkbook.Path | Dim URLStr as String URLStr = ThisComponent.getURL() GlobalScope.BasicLibraries.LoadLibrary("Tools") $1 = DirectoryNameoutofPath(URLStr, ""/"") |
| Application.PathSeparator | getPathSeparator |
| .*? = ActiveWorkbook.Name | Dim URLStr as String Dim $1 as String GlobalScope.BasicLibraries.LoadLibrary("Tools") URLStr = ThisComponent.getURL() $1 = FileNameOutOfPath(URLStr) |
| .*? = Range(.*?).Address | Dim oSheet as Object oSheet = ThisComponent.CurrentController.ActiveSheet $1 = CellRangeAddressString(oSheet.getCellRangeByName($2)) |
| Worksheets(.*?).Activate | Dim oSheet as Object oSheet = ThisComponent.Sheets.getByName($1) ThisComponent.CurrentController.setActiveSheet(oSheet) |
| If .*?.Value = True Then | Dim oDlg as Object Rem oDlg should be at module level if oDlg.getControl("$1").getState() = True Then |
| Worksheets(.*?).Delete | ThisComponent.Sheets.removeByName($1) |
| Range(.*?).Select | Dim oSheet as Object oSheet = ThisComponent.CurrentController.ActiveSheet ThisComponent.CurrentController.select(oSheet.getCellRangeByName($1)) |
| Range(.*?).Value | ThisComponent.CurrentController.ActiveSheet.getCellRangeByName($1).Value |
| Range(.*?).Clear | getCellRangeByName($1).clearContents(com.sun.star.sheet.CellFlags.VALUE + com.sun.star.sheet.CellFlags.STRING + com.sun.star.sheet.CellFlags.DATETIME + com.sun.star.sheet.CellFlags.ANNOTATION + com.sun.star.sheet.CellFlags.FORMULA + com.sun.star.sheet.CellFlags.HARDATTR + com.sun.star.sheet.CellFlags.STYLES + com.sun.star.sheet.CellFlags.OBJECTS + com.sun.star.sheet.CellFlags.EDITATTR) |
| Range(.*?).Text | ThisComponent.CurrentController.ActiveSheet.getCellRangeByName($1).String |
| Worksheets(.*?) | ThisComponent.Sheets.getByName($1) |
| ActiveWorksheet | ThisComponent.CurrentController.ActiveSheet |
| Worksheets.Add | Dim oSheets oSheets = ThisComponent.Sheets oSheets.insertNewByName("$1", oSheets.getCount()) |
| Number to Text | Number to txt |
| ActiveWorkbook | ThisComponent |
| .*?.ListIndex | Dim oDlg as Object Rem oDlg should be at module level - listindex should instead be the text of the combo box oDlg.getControl($1).Text |
| ClearContents | clearContents(com.sun.star.sheet.CellFlags.VALUE + com.sun.star.sheet.CellFlags.STRING + com.sun.star.sheet.CellFlags.DATETIME) |
| .addItem .*? | Rem change 0 to array order 0 to count |1|.addItem($1,0) |
| ActiveSheet | ThisComponent.CurrentController.ActiveSheet |
| ActiveCell | ThisComponent.getCurrentSelection |
| .*?.Close | $1.Close(False) |
| Range.*? | Dim oSheet as Object oSheet = ThisComponent.CurrentController.ActiveSheet oSheet.getCellRangeByName($1) |
| .*?.Show | Rem oDlg should be visible at the module level Dim oDlg As Object DialogLibraries.LoadLibrary("Standard") oDlg = CreateUnoDialog(DialogLibraries.Standard.$1) oDlg.execute() |