Align To Anchor macro being ignored?

So I have a real simple macro which inserts an image, sets the anchor to the page and should then set the image to ‘Align Bottom to Anchor’.

Only problem is the last part seems to be ignored within the macro code. I end up with the image being inserted and then it sits at the top of the page after the anchor is set. I need to get the image sitting at the bottom of the page. Am I being stupid here?

Sub InsertFooter
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dim args1(3) as new com.sun.star.beans.PropertyValue
args1(0).Name = "FileName"
args1(0).Value = "file:///C:/Program%20Files%20(x86)/Images/Addresses/Footer.png"

dispatcher.executeDispatch(document, ".uno:InsertGraphic", "", 0, args1())

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:SetAnchorToPage", "", 0, Array())

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:AlignBottom", "", 0, Array())
end sub

Thanks in advance!

That’s what you get with the very imperfect macro recorder. It doesn’t work here because the array() variable hasn’t been properly initialised. You will have to dive into the UNO API to get this to work. You can get more help at Index page • Apache OpenOffice Community Forum

You should try pitonyak’s extended usage of macros. There are multiple examples (still working) on how and where to insert an image.