ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Setting TopMargin Property in VBA (https://www.excelbanter.com/excel-programming/279896-setting-topmargin-property-vba.html)

John S.[_3_]

Setting TopMargin Property in VBA
 
Hi;
Is it possible to make Excel take the TopMargin value from
a variable or a cell. I tried a number of variations and
VBA keeps sending message: 'object does not support this
property or method'
e.g.
....
upmargin = Range("l2")
prtsheet.TopMargin = Application.InchesToPoints(upmargin)
....

Thanks.

steve

Setting TopMargin Property in VBA
 
John,

Try this:

With ActiveSheet.PageSetup
.TopMargin = Application.InchesToPoints(Range("A1"))
End With

or
x = 0.5
With ActiveSheet.PageSetup
.TopMargin = Application.InchesToPoints(x)
End With

--
sb
"John S." wrote in message
...
Hi;
Is it possible to make Excel take the TopMargin value from
a variable or a cell. I tried a number of variations and
VBA keeps sending message: 'object does not support this
property or method'
e.g.
...
upmargin = Range("l2")
prtsheet.TopMargin = Application.InchesToPoints(upmargin)
...

Thanks.




Chip Pearson

Setting TopMargin Property in VBA
 
John,

TopMargin is a property of the PageSetup object, so try something like

prtsheet.PageSetup.TopMargin = Application.InchesToPoints(Range("A1").Value)



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"John S." wrote in message
...
Hi;
Is it possible to make Excel take the TopMargin value from
a variable or a cell. I tried a number of variations and
VBA keeps sending message: 'object does not support this
property or method'
e.g.
...
upmargin = Range("l2")
prtsheet.TopMargin = Application.InchesToPoints(upmargin)
...

Thanks.





All times are GMT +1. The time now is 06:55 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com