Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- REM ***** BASIC ***** FOR Those who are wanting to learn about Libre Office Calc Macro's with forms ****
- REM **** Video Tutorial On Facebook for those who would like to see intro to this @
- REM ******** https://www.facebook.com/mark.harrington.142892 *****************
- sub PopRange
- dim cell as object
- dim i as variant
- dim sheets
- sheet = thiscomponent.sheets(0)
- i = 0.0
- while i < 40.0
- cell = Sheet.getCellByPosition(0,i)
- cell.setValue( i )
- i = i+1
- call ExampleWait
- wend
- End Sub
- REM Function to give delay
- Sub ExampleWait
- Dim lTick As Long
- lTick = GetSystemTicks()
- Wait 500
- End Sub
- REM ******* function to clear cell contents
- Sub ClearRangeContents
- Dim oFlags As Long
- oFlags = com.sun.star.sheet.CellFlags.VALUE + _
- com.sun.star.sheet.CellFlags.DATETIME + _
- com.sun.star.sheet.CellFlags.STRING + _
- 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
- ThisComponent.Sheets(0).GetCellRangeByName("A1:A40").ClearContents(oFlags)
- End Sub
- REM ***** Function that checks for odd numbers and colors cells background color
- Sub Check_ForODD_Numbers
- Dim oRange As Object
- Dim oCell As Object
- Dim oSheet As Object
- ODDcolor = RGB(255,0,0)
- EvenColor = RGB(0,0,255)
- oSheet = ThisComponent.sheets(0)
- oRange = oSheet.getCellRangebyName("A1:A40")
- Dim i As Integer, j As Integer
- For i = 0 To oRange.Rows.getCount() - 1 REM Traverse all cells in the specified range:
- For j = 0 To oRange.Columns.getCount() - 1
- oCell = oRange.getCellByPosition( j, i )
- mval =oCell.Value 'get the value
- m_odd = mval mod 2
- if m_odd <> 0 then
- oCell.CellBackColor = ODDcolor
- else
- oCell.CellBackColor = EvenColor
- end if
- call ExampleWait
- next j
- next i
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement