excel vba 怎么查看当前工作表可打印的总页数,和某一页的所在的页数, 10
展开全部
Sub 定义页码及总页数名称()
'
' 定义页码及总页数名称 Macro
' 宏由 cbtaja 录制,时间: 2010-5-12
'
'
ActiveWorkbook.Names.Add Name:="ColFirst", RefersToR1C1:= _
"=GET.DOCUMENT(61)" '判断打印顺序的设置类型
ActiveWorkbook.Names.Add Name:="lstRow", RefersToR1C1:= _
"=GET.DOCUMENT(10)" '本工作表已用到的最大行数
ActiveWorkbook.Names.Add Name:="lstColumn", RefersToR1C1:= _
"=GET.DOCUMENT(12)" '本工作表已用到的最大列数
ActiveWorkbook.Names.Add Name:="hNum", RefersToR1C1:= _
"=IF(ISERROR(FREQUENCY(GET.DOCUMENT(64),Row())),0,FREQUENCY(GET.DOCUMENT(64),Row()))" 'hNum为本单元格上方的水平分页符个数
ActiveWorkbook.Names.Add Name:="vNum", RefersToR1C1:= _
"=IF(ISERROR(FREQUENCY(GET.DOCUMENT(65),Column())),0,FREQUENCY(GET.DOCUMENT(65),Column()))" ''本单元格左边的垂直分页个数
ActiveWorkbook.Names.Add Name:="hSum", RefersToR1C1:= _
"=IF(ISERROR(FREQUENCY(GET.DOCUMENT(64),lstRow)),0,FREQUENCY(GET.DOCUMENT(64),lstRow))" ''本工作表最后一个单元格上方的水平分页符个数
ActiveWorkbook.Names.Add Name:="vSum", RefersToR1C1:= _
"=IF(ISERROR(FREQUENCY(GET.DOCUMENT(65),lstColumn)),0,FREQUENCY(GET.DOCUMENT(65),lstColumn))" ''本工作表最后一个单元格左边的垂直分页个数
ActiveWorkbook.Names.Add Name:="ThisPageNo", RefersToR1C1:= _
"=IF(ColFirst,(hSum+1)*vNum+hNum+1,(vSum+1)*hNum+vNum+1)*ISNUMBER(NOW())" '单元格所在页码
ActiveWorkbook.Names.Add Name:="PagesCount", RefersToR1C1:= _
"=GET.DOCUMENT(50)*ISNUMBER(NOW())" '本工作表的总页数
End Sub
'
' 定义页码及总页数名称 Macro
' 宏由 cbtaja 录制,时间: 2010-5-12
'
'
ActiveWorkbook.Names.Add Name:="ColFirst", RefersToR1C1:= _
"=GET.DOCUMENT(61)" '判断打印顺序的设置类型
ActiveWorkbook.Names.Add Name:="lstRow", RefersToR1C1:= _
"=GET.DOCUMENT(10)" '本工作表已用到的最大行数
ActiveWorkbook.Names.Add Name:="lstColumn", RefersToR1C1:= _
"=GET.DOCUMENT(12)" '本工作表已用到的最大列数
ActiveWorkbook.Names.Add Name:="hNum", RefersToR1C1:= _
"=IF(ISERROR(FREQUENCY(GET.DOCUMENT(64),Row())),0,FREQUENCY(GET.DOCUMENT(64),Row()))" 'hNum为本单元格上方的水平分页符个数
ActiveWorkbook.Names.Add Name:="vNum", RefersToR1C1:= _
"=IF(ISERROR(FREQUENCY(GET.DOCUMENT(65),Column())),0,FREQUENCY(GET.DOCUMENT(65),Column()))" ''本单元格左边的垂直分页个数
ActiveWorkbook.Names.Add Name:="hSum", RefersToR1C1:= _
"=IF(ISERROR(FREQUENCY(GET.DOCUMENT(64),lstRow)),0,FREQUENCY(GET.DOCUMENT(64),lstRow))" ''本工作表最后一个单元格上方的水平分页符个数
ActiveWorkbook.Names.Add Name:="vSum", RefersToR1C1:= _
"=IF(ISERROR(FREQUENCY(GET.DOCUMENT(65),lstColumn)),0,FREQUENCY(GET.DOCUMENT(65),lstColumn))" ''本工作表最后一个单元格左边的垂直分页个数
ActiveWorkbook.Names.Add Name:="ThisPageNo", RefersToR1C1:= _
"=IF(ColFirst,(hSum+1)*vNum+hNum+1,(vSum+1)*hNum+vNum+1)*ISNUMBER(NOW())" '单元格所在页码
ActiveWorkbook.Names.Add Name:="PagesCount", RefersToR1C1:= _
"=GET.DOCUMENT(50)*ISNUMBER(NOW())" '本工作表的总页数
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询