|Keep It Simple, Stupid|
Issues in Setting Word margins using Win32::OLEby shantanu_bhadoria (Novice)
|on May 27, 2008 at 07:45 UTC||Need Help??|
shantanu_bhadoria has asked for the
wisdom of the Perl Monks concerning the following question:
Hi I had this unique issue with setting page margins for a word file using Win32::OLE
The ides is to set right and left margins for any word document. here is the snippet of code i am having trouble with :
The issue with this is that if the papersize is such that width is 8 and the initial right margin for the document before editing was 7.
the Win32::OLE::with function sets the margins in sequence and not together. so if i want to set margins to 2 and 2 in the file, I won't be able to do that since when OLE tries to set the left margin to 2 the word app croaks, since the right margin is still 7 and paper size is 8 so can't have left and right margins of 7 and 2 for a paper width of 8.
the with in VBA allows this adjustment when we pass multiple params to the VBA with() , so I looked into the Win32/OLE/Lite.pm and saw that the with() function is simply a perl implementation of the VBA function which traverses the hash the perl way without any adjustments as required above. Does anyone know a way I can resolve the issue. An obvious hack around this issue is to set both margins to 0 first and then to the desired value but i wish there was a cleaner way to do this. Maybe by calling the VBA with() directly in some way. Just blurbing in the dark here, would appreciate some pointers.