Setting TopMargin Property in VBA

  • Thread starter Thread starter John S.
  • Start date Start date
J

John S.

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.
 
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
 
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 (e-mail address removed)
 
Back
Top