源代码 新建一个excel文件,alt+F11打开VBA粘贴一下代码,另存为加载宏(*.xla),在工具菜单中,单击加载宏,加载之。 或者用下面宏文件,直接加载
Private Sub Workbook_Open() Dim i% For j = 1 To Application.CommandBars.Count For i = 1 To Application.CommandBars(j).Controls.Count If Application.CommandBars(j).Controls.Item(i).TooltipText = "打印当前页(&C)" Then Exit Sub End If Next Next Set mybar = Application.CommandBars("Worksheet Menu Bar").Controls.Add(Type:=msoControlButton, ID:=2950, Before:=11) mybar.Caption = "打印当前页(&C)" mybar.TooltipText = "打印当前页(&C)" mybar.OnAction = "打印当前页" End Sub
Sub 打印当前页() a = ActiveSheet.HPageBreaks.Count b = ActiveSheet.VPageBreaks.Count For n = 1 To a c = ActiveSheet.HPageBreaks(n).Location.Row f = ActiveCell.Row If c > f Then Exit For Next For m = 1 To b d = ActiveSheet.VPageBreaks(m).Location.Column e = ActiveCell.Column If d > e Then Exit For Next If ActiveSheet.PageSetup.Order = xlOverThenDown Then g = (n - 1) * (b + 1) + m Else g = (m - 1) * (a + 1) + n End If ActiveSheet.PrintOut from:=g, to:=g End Sub 加载宏下载
eKa9tMoZ.rar
(7.27 KB, 下载次数: 108)
[此贴子已经被作者于2007-6-1 10:43:12编辑过] |