C
CL
Hi all,
I had pre-determined the number of rows for the quotation table for each and
every print page so that the page print will be constant
However, I would like to state that my problem is that whenever I expand any
row height within the table, there is a high chance that the number of rows
of table in each print page will also change.
And using my method to pre-determine the number of rows for the quotation
table, the macro will put a bordering at the wrong row (if I have change to
height of some rows within the same page, thus forcing previous rows at the
end to go to next print page)
I am also getting VBA to generate a print preview immediately after hitting
the "Convert to Quotation Form" button, so you will see that all formating
and resizing has been fixed to standardize the quotation print output.
Please help and advice me on how to get VBA to recognize the last row count
for each print page to be dynamic, instead of my current hard-coded counting
of rows for each printed page.
I am currently using these code for hard-coding:-
With destSh.PageSetup
.PrintArea = "$A1:$H" & lastprintable
.PrintTitleRows = "$1:$21"
.Zoom = 44
' .FitToPagesWide = 1
' .FitToPagesTall = 8
.PrintErrors = xlPrintErrorsDisplayed
' .RightFooter = "&8Printed on : " & _
Format(ThisWorkbook.BuiltinDocumentProperties("Last Print
Date"), _
"yyyy-mmm-dd hh:mm:ss")
.CenterFooter = "Page &P of &N"
.TopMargin = Application.InchesToPoints(0.75)
.BottomMargin = Application.InchesToPoints(0.75)
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.75)
.CenterHorizontally = True
.CenterVertically = False
.Orientation = xlPortrait
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
End With
'for automatic border underline
ub = 109
For fndline = ub To lastprintable
If lastprintable > ub Then
destSh.Range(Cells(ub, 1), Cells(ub, 8)).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
ub = ub + 90 ' how to change 90 to be dynamic??
End If
Next fndline
pages = ExecuteExcel4Macro("Get.Document(50)")
destSh.Range("D12").Value = "Pages (Incl this page) : "
Thank you once again.
Cheers,
CL
I had pre-determined the number of rows for the quotation table for each and
every print page so that the page print will be constant
However, I would like to state that my problem is that whenever I expand any
row height within the table, there is a high chance that the number of rows
of table in each print page will also change.
And using my method to pre-determine the number of rows for the quotation
table, the macro will put a bordering at the wrong row (if I have change to
height of some rows within the same page, thus forcing previous rows at the
end to go to next print page)
I am also getting VBA to generate a print preview immediately after hitting
the "Convert to Quotation Form" button, so you will see that all formating
and resizing has been fixed to standardize the quotation print output.
Please help and advice me on how to get VBA to recognize the last row count
for each print page to be dynamic, instead of my current hard-coded counting
of rows for each printed page.
I am currently using these code for hard-coding:-
With destSh.PageSetup
.PrintArea = "$A1:$H" & lastprintable
.PrintTitleRows = "$1:$21"
.Zoom = 44
' .FitToPagesWide = 1
' .FitToPagesTall = 8
.PrintErrors = xlPrintErrorsDisplayed
' .RightFooter = "&8Printed on : " & _
Format(ThisWorkbook.BuiltinDocumentProperties("Last Print
Date"), _
"yyyy-mmm-dd hh:mm:ss")
.CenterFooter = "Page &P of &N"
.TopMargin = Application.InchesToPoints(0.75)
.BottomMargin = Application.InchesToPoints(0.75)
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.75)
.CenterHorizontally = True
.CenterVertically = False
.Orientation = xlPortrait
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
End With
'for automatic border underline
ub = 109
For fndline = ub To lastprintable
If lastprintable > ub Then
destSh.Range(Cells(ub, 1), Cells(ub, 8)).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
ub = ub + 90 ' how to change 90 to be dynamic??
End If
Next fndline
pages = ExecuteExcel4Macro("Get.Document(50)")
destSh.Range("D12").Value = "Pages (Incl this page) : "
Thank you once again.
Cheers,
CL