標題:
[發問]
如何得到當前列印範圍頁數?
[打印本頁]
作者:
naruto018
時間:
2017-4-5 10:56
標題:
如何得到當前列印範圍頁數?
如何得到當前列印範圍頁數?
我想要在VBA中間加入判斷當前列印範圍頁數是否超過2頁
Public Sub 列印()
With Worksheets("1111")
.PageSetup.PrintArea = .Range(Cells(1, 1), Cells(Rows.Count, 9)).Address '設定列印範圍
'<---加入判斷頁面是否超過2頁
MyPage = 1 '<---獲得當前列印範圍頁數
If MyPage > 2 Then '<---判斷當前列印範圍頁數
MsgBox "頁面超過2頁,請重新調整頁面,再列印"
Else
.PrintOut Copies:=1, Collate:=True, IgnorePrintAreas:=False '列印
End If
End With
End Sub
複製代碼
作者:
准提部林
時間:
2017-4-9 10:47
HP = ActiveSheet.HPageBreaks.Count + 1 '縱向頁數
VP = ActiveSheet.VPageBreaks.Count + 1 '橫向頁數
PG = HP * VP '總頁數
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)