Office中国论坛/Access中国论坛

标题: 用那个函数或用什么方法可以判断出所在页的页码? [打印本页]

作者: bfwz    时间: 2006-6-16 14:32
标题: 用那个函数或用什么方法可以判断出所在页的页码?
用那个函数或用什么方法可以判断出所在页的页码?
作者: chenchunhuiabc    时间: 2006-6-18 04:15
分页显示就可以啊
作者: zsj1101    时间: 2006-6-28 16:12
Sub PrintActivePage()

    Dim VPC     As Integer

    Dim HPC     As Integer

    Dim VPB     As VPageBreak

    Dim HPB     As HPageBreak

    Dim NumPage As Integer

   

    If ExecuteExcel4Macro("Get.Document(50)") = 0 Then

       MsgBox "Excel 找不到列印的內容"

       Exit Sub

    End If

   

    If ExecuteExcel4Macro("Get.Document(50)") = 1 Then

        ActiveSheet.PrintOut From:=1, To:=1, Copies:=1

        Exit Sub

    End If

   

    '先判斷編頁碼的順序也就是版面設定的循欄列印或循列列印

    If ActiveSheet.PageSetup.Order = xlDownThenOver Then

        HPC = ActiveSheet.HPageBreaks.Count + 1

        VPC = 1

    Else

        VPC = ActiveSheet.VPageBreaks.Count + 1

        HPC = 1

    End If

   

    NumPage = 1

   

    Application.ScreenUpdating = True

    ActiveWindow.View = xlPageBreakPreview

    For Each VPB In ActiveSheet.VPageBreaks

        If VPB.Location.Column > ActiveCell.Column Then Exit For

        NumPage = NumPage + HPC

    Next VPB

   

    For Each HPB In ActiveSheet.HPageBreaks

        If HPB.Location.Row > ActiveCell.Row Then Exit For

        NumPage = NumPage + VPC

    Next HPB

   

    '取得頁數後再判斷目前儲存格是否在列印範圍中

    If Intersect(ActiveSheet.UsedRange, ActiveCell) Is Nothing Then

        MsgBox "目前儲存格不在列印範圍中"

    Else

        MsgBox "目前儲存格在第" & NumPage & "頁"

        ActiveSheet.PrintOut From:=NumPage, To:=NumPage, Copies:=1

    End If

    ActiveWindow.View = xlNormalView

    Application.ScreenUpdating = True

End Sub
作者: bfwz    时间: 2006-7-4 22:51
谢谢,就是有点复杂


作者: zhaopin616    时间: 2006-7-4 23:13
[em03]太复杂




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3