Getting error- see comments in my code I pasted for where I get the error… If it’s because I need a different format string, what format string should I use to format the cell as a date?
function test9
	Dim Doc As Object
	Dim Sheet As Object
	Dim Cell As Object
	Dim NumberFormats As Object
	Dim NumberFormatString As String
	Dim NumberFormatId As Long
	Dim LocalSettings As New com.sun.star.lang.Locale
	
	Doc = ThisComponent
	Sheet = Doc.Sheets.getByName("Details by CSR")
	msgbox sheet.name
	Cell = Sheet.getCellByPosition(0,0)
	
	Cell.Value = 44819 '"9/1/2022"
	
	LocalSettings.Language = "en"
	LocalSettings.Country = "us"
	
	NumberFormats = Doc.NumberFormats
	NumberFormatString = "M/dd/yyyy"			'What should I use to format as a date? Tried lots of things.
	
	NumberFormatId = NumberFormats.queryKey(NumberFormatString, LocalSettings, True)
	If NumberFormatId = -1 Then
		'Next line gives RunTime error '1' : RunTimException
	  NumberFormatId = NumberFormats.addNew(NumberFormatString, LocalSettings)
	End If
	
	MsgBox NumberFormatId
	Cell.NumberFormat = NumberFormatId
End Function
