Make a Macro Work Only in the Footnote Area

Please,

I have this macro and I want it to be applied only in the footnote area:

    Sub MyStyles

Dim oDoc as Object
Dim oText as object
Dim oPar as object
Dim bAlternate as boolean


oDoc = ThisComponent
oText = oDoc.getText()
bAlternate = false

oParEnum = oText.createEnumeration()
Do While oParEnum.hasMoreElements()
    oPar = oParEnum.nextElement()
    REM This avoids the tables. Add an else statement if you want to process the tables.
    If oPar.supportsService("com.sun.star.text.Paragraph") Then
        If bAlternate then
            oPar.ParaStyleName = "MyStyle1"
        else
            oPar.ParaStyleName = "MyStyle2"
        end if
    end if
    bAlternate = not bAlternate
loop
end Sub

I studied Andrew Pitonyak’s files and found this code:

 oNotes = ThisComponent.getFootnotes()
  For i = 0 To oNotes.getCount() - 1
    oNote = oNotes.getByIndex(i)

And also this:

fnotes=xdoc.getFootNotes()
If fnotes.hasElements() Then
    fnotecount=0
    For nfnotes=0 To fnotes.getCount()-1
        thisnote=fnotes.getbyIndex(nfnotes)
        startcursor=thisnote.getStart()

But I can’t get it to work in the above Macro. Can anyone help, please?

Thanks,

Use the extension Xray to examine the properties and methods of the programming objects.

Sub MyStyles
    Dim oDoc as object
    Dim bAlternate as boolean
    Dim oNotes as object
    Dim oNote as object 
    Dim i as integer   

    oDoc = ThisComponent
	bAlternate = false
	oNotes = oDoc.getFootnotes()
	For i = 0 To oNotes.getCount() - 1
		oNote = oNotes.getByIndex(i)
REM		Xray oNote
		If bAlternate then
			oNote.Start.ParaStyleName = "MyStyle1"
		else
			oNote.Start.ParaStyleName = "MyStyle2"
		end if
		bAlternate = not bAlternate
	next i
	
end Sub

Delete te “REM” from the code (after you installed thew Xray):
https://berma.pagesperso-orange.fr/index2.html

Perfect! Thanks!