I’ve been trying to copy and rename a sheet using this code:
Sub Main
sheet = "Vorlage"
newsheet = format(now, "MMMM") + format(now, "YYYY")
doc = ThisComponent
sheets = doc.getSheets
If sheets.hasByName(sheet) Then
sheets.CopyByName(sheet, newsheet, sheets.Count - 1)
Else
MsgBox("Vorlage fehlt")
EndIf
End Sub
Since my locale is German, the format(now,“MMMM”) will yield the result “März”. Which leads to this error:
Type: com.sun.star.uno.RuntimeException
Message: .
The code runs fine if I only use the year. So how do I fix this?