I'm trying to convert my Excel VBA macro into OpenOffice Calc Basic macro, but I have some difficulties understanding how OpenOffice's objects work (dispatcher, etc.)
I would appreciate your help. My VBA code:
Code: Select all
Option Explicit
Sub CreateSheetForEachDayOfYear()
Dim arrHolidays As Variant, arrShortDays As Variant
Dim datStartOfTheYear As Date, datEndOfTheYear As Date, datSingleDay As Date
Dim varCounter As Variant
datStartOfTheYear = #1/1/2020#
datEndOfTheYear = #12/31/2020#
arrHolidays = Array(#1/1/2020#, #1/2/2020#, #1/3/2020#, #1/4/2020#, #1/5/2020#, #1/6/2020#, #1/7/2020#, #1/8/2020#, #2/23/2020#, #2/24/2020#, #3/8/2020#, #3/9/2020#, #5/1/2020#, #5/9/2020#, #5/11/2020#, #6/12/2020#, #11/4/2020#)
arrShortDays = Array(#4/30/2020#, #5/8/2020#, #6/11/2020#, #11/3/2020#, #12/31/2020#)
Application.ScreenUpdating = False
For datSingleDay = datStartOfTheYear To datEndOfTheYear
Sheets.Add After:=ActiveSheet
ActiveSheet.Select
ActiveSheet.Name = Format(datSingleDay, "dd mmm")
Range("A1:J1").Merge
With Range("A1")
.HorizontalAlignment = xlCenter
With .Font
.Size = 14
.Bold = True
End With
.Value = StrConv(Format(datSingleDay, "dddd, "), 3) & Format(datSingleDay, "dd mmmm yyyy")
End With
For Each varCounter In arrHolidays
If CDate(varCounter) = datSingleDay Then
Range("A1").Font.Color = 255
ActiveSheet.Tab.Color = 255
End If
Next
For Each varCounter In arrShortDays
If CDate(varCounter) = datSingleDay Then
Range("A1").Font.Color = 12611584
ActiveSheet.Tab.Color = 12611584
End If
Next
If Weekday(CDate(datSingleDay)) = 1 Or Weekday(CDate(datSingleDay)) = 7 Then
Range("A1").Font.Color = 255
ActiveSheet.Tab.Color = 255
End If
Range("A3").Select
Next
Application.DisplayAlerts = False
shtButtonSheet.Delete
Application.DisplayAlerts = True
Worksheets(1).Select
Application.ScreenUpdating = True
End Sub