PageStyle questions part 2

I originally asked the question on March 2. I have learned a lot since then, but the fundamental question remains: How do I create PageStyles? I know that I can manually create and apply them through the IDE. I want to use a program to do it. I have found a number of parameters related to the pagestyle(LibreOffice: PageProperties Service Reference).
I need to be able to do the following:

  • Find the methods used to add and assign a pagestyle.

  • Find the parameters required to change the Text attributes on the header and footer (specifically the size and Bold/Italic/Underline).

  • Parameters to locate (Left/Center/Right) the fields in the Left/Center/Right areas of the header/footer.

  • Now the tough one. In the IDE I can add Sheet Name, Page, Pages, Date, Time. These are all dynamic items. For example, the Time option. I can add the time (Time()) however that is static. Regardless of when I print the spreadsheet, the date remains the same. However if I select the Time option in the IDE, this is dynamic. Whenever I print the spreadsheet, the time on the header/footer will be the current time.
    I tried to trick it. The center field in the Header is the Sheet name. In my case it is one of the 12 months, or Summary. I tried different things to get what I need:
    '*************************************************************************
    HContent = .RightPageHeaderContent 'Right header sets right and left pages
    With HContent
    HText = .LeftText
    HText.String = date() 'Current static date
    HText = .CenterText

        '*************************************************************************
        'HText.string = "John " & HText.string		'Result is "John ???"
        'HText.String = sheet.name				'Puts the same name on all sheets
        'If HText.string is not set each page has the correct page name
        '*************************************************************************
        HText =.RightText
        HText.String = Time()                                   'Current static date
      End With
      .RightPageHeaderContent = HContent		'Restore Header content
      '*************************************************************************
    

I thought that the HText string for the Sheet name might have some unprintable characters. It does not. I need to be able to add these fields to the header/footer.

Any help on any of these items would be greatly appreciated.
Thank you
John

One problem solved another one created. I was looking for another problem, and came across a response by [mrkalvin] from June 23which told how to add, and attach a new PageStyle. It was not written in Basic, but I was able to adapt it.
here is what I came up with:
PageStyles = Doc.StyleFamilies.getByName(“PageStyles”) 'Get PageStyles containes

'If the pagestyle does not exist, then create it
if Pagestyles.hasByName("BP_" & sheet.name) = False then				'Not found
    pagestyle = Doc.createInstance("com.sun.star.style.PageStyle")		'Create it
    pagestyles.insertByName("BP_" & sheet.name, pagestyle)				'Insert it

   'Apply Page Style
    sheet.PageStyle = "BP_" & sheet.name							'Apply it to the current sheet
end if
 
'******************************************************************
'* Make sure it was created. BP_Monthname/Summary will be replaced*
'* by Month.                                                      *
'******************************************************************
found = false    
For i = 0 To PageStyles.Count - 1										'Loop through pagestyles
  PageStyle = PageStyles(i)												'Get next
  
  if PageStyle.Name = "BP_" & sheet.name then							'Correct one?
    found = true														'Yes, set true
    exit for															'Stop looking
  end if  
Next

To try to keep with the rules, I will submit the new problem under a new topic.
John