ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   margins do not fit page size error (https://www.excelbanter.com/excel-programming/279963-margins-do-not-fit-page-size-error.html)

Mike Kim

margins do not fit page size error
 
hi there,

I have aVB.net app that create a excel workseet on the fly. and i want to
set up all margins to 0.
I tried the following and got an error message saying "margins do not fit
page size". i was able to do almost anything like setting a font for a cell
and so forth ... but no this.

'
' of course i have declare objects on top
'
objSheet.PageSetup.FooterMargin = objApp.InchesToPoints(0)
objSheet.PageSetup.BottomMargin = objApp.InchesToPoints(0)
objSheet.PageSetup.TopMargin = objApp.InchesToPoints(0)
objSheet.PageSetup.BottomMargin = objApp.InchesToPoints(0)
objSheet.PageSetup.LeftMargin = objApp.InchesToPoints(0)
objSheet.PageSetup.RightMargin = objApp.InchesToPoints(0)

I have zebra barcode label printer as a default printer and set 1.25" X
1.00" as a default paper size.
please help me.



keepITcool

margins do not fit page size error
 
some printerdrivers just wont accept 0 margins.
(you could try fiddling around in the printer
driver's install.. PPD files...)

however to minimize margins try like following:

in vba (not NET) this works...

Sub minMargins()
On Error Resume Next
With ActiveSheet.PageSetup
Debug.Print .TopMargin, .BottomMargin, .LeftMargin, .RightMargin
.TopMargin = 0
.BottomMargin = 0
.LeftMargin = 0
.TopMargin = 0
Debug.Print .TopMargin, .BottomMargin, .LeftMargin, .RightMargin
.TopMargin = .BottomMargin / 2
.BottomMargin = .TopMargin
.LeftMargin = .RightMargin / 2
.RightMargin = .LeftMargin
Debug.Print .TopMargin, .BottomMargin, .LeftMargin, .RightMargin
End With
End Sub


keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Mike Kim" wrote:

hi there,

I have aVB.net app that create a excel workseet on the fly. and i want
to set up all margins to 0.
I tried the following and got an error message saying "margins do not
fit page size". i was able to do almost anything like setting a font
for a cell and so forth ... but no this.

'
' of course i have declare objects on top
'
objSheet.PageSetup.FooterMargin = objApp.InchesToPoints(0)
objSheet.PageSetup.BottomMargin = objApp.InchesToPoints(0)
objSheet.PageSetup.TopMargin = objApp.InchesToPoints(0)
objSheet.PageSetup.BottomMargin = objApp.InchesToPoints(0)
objSheet.PageSetup.LeftMargin = objApp.InchesToPoints(0)
objSheet.PageSetup.RightMargin = objApp.InchesToPoints(0)

I have zebra barcode label printer as a default printer and set 1.25"
X 1.00" as a default paper size.
please help me.





All times are GMT +1. The time now is 02:59 AM.

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