Setting TopMargin Property in VBA

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.
 
S

steve

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
 
C

Chip Pearson

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top