Print Method Explanation and Elaboration

Hello,

I have a Writer document that has dynamically changing content and thus needs a macro to effectively print (instead of hundreds of manual print dialogues) and I am fiddling around with some print methods and properties found at:
http://www.pitonyak.org/OOME_3_0.pdf. Everything in my macros for my dynamic document all work correctly (including the general print property changes), besides the PagePrintSettings. The PagePrintSettings seem to fail at runtime and I am not sure why. Are the margins supposed to not be a string? I have tried making them both integers and floats to no success (as well as strings, obviously). I am sure I have made a small mistake somewhere. Can anyone explain a little bit of the print properties/methods and give some working examples? Also, are the margins in TWIPS? Is that perhaps why it is not working?

Sub TemporaryWriterPrintPropertyTesting

rem Define variables.
Dim printerOption(0) As New com.sun.star.beans.PropertyValue
Dim pagePrinterOption(0 to 4) As New com.sun.star.beans.PropertyValue

rem Set "general" print properties.
printerOption(0).Name = "DuplexMode"
printerOption(0).Value = com.sun.star.view.DuplexMode.SHORTEDGE
ThisComponent.Printer = printerOption()

rem Set Writer exclusive print properties.
pagePrinterOption(0).Name = "LeftMargin"
pagePrinterOption(0).Value = "0.25"
pagePrinterOption(1).Name = "RightMargin"
pagePrinterOption(1).Value = "0.25"
pagePrinterOption(2).Name = "TopMargin"
pagePrinterOption(2).Value = "0.25"
pagePrinterOption(3).Name = "BottomMargin"
pagePrinterOption(3).Value = "0.25"
pagePrinterOption(4).Name = "IsLandscape"
pagePrinterOption(4).Value = True


rem "BASIC runtime error.;                                     An exception occurred;  
rem  Type: com.sun.star.uno.RuntimeException;                  Message: ."
rem
rem This line is where I get the error above V
ThisComponent.setPagePrintSettings(pagePrinterOption()) 
End Sub

Ah, I have figured out the problem. I was a goof and the margins actually need to be TWIPS. facepalm

So, each margin would be set to the integer 360 (1440 TWIPS = 1 Inch).

However, it doesn’t seem the duplex option is being set; is there a reason for that?