发布网友 发布时间:2022-04-25 15:10
共1个回答
热心网友 时间:2023-04-29 05:07
1、第一种写法:Sub PrintRL()'代码作用:在打印EXCEL文件时连续打印奇偶页'当为奇数时页脚设在右边,为偶时设在左边并打印'By redwin for yan'2007-4-16Dim Numb As IntegerOn Error Resume Next'得到当前工作簿的打印页数NumbNumb = ExecuteExcel4Macro("Get.Document(50)")'MsgBox NumbWith ActiveSheet.PageSetupFor i = 1 To Numb Step 1If i Mod 2 = 1 Then.LeftFooter = "".RightFooter = "第 &P 页,共 &N 页"ActiveWindow.SelectedSheets.PrintOut From:=i, To:=iElse.RightFooter = "".LeftFooter = "第 &P 页,共 &N 页"ActiveWindow.SelectedSheets.PrintOut From:=i, To:=iEnd IfNext iEnd WithEnd Sub2、第二种写法:Sub PrintRL()'代码作用:在打印EXCEL文件时分开打印奇偶页'当为奇数时页码页脚设在右边,为偶时设在左边'By redwin for yan'2007-4-16Dim Numb As IntegerDim Numb1 As IntegerOn Error Resume Next'得到当前工作簿的打印页数NumbNumb = ExecuteExcel4Macro("Get.Document(50)")'MsgBox NumbWith ActiveSheet.PageSetup'先打印奇数页;考虑到放纸习惯,先设置好第一张的页码问题If Numb Mod 2 <> 1 ThenNumb1 = Numb - 1ElseNumb1 = NumbEnd IfFor i = Numb1 To 1 Step -2.LeftFooter = "".RightFooter = "第 &P 页,共 &N 页"ActiveWindow.SelectedSheets.PrintOut From:=i, To:=iNext iMsgBox "注意:奇数页已打印完毕,下面将打印偶数页,请注意放纸,确定后便开始喽!", _vbInformation, "双面打印,将节约进行到底:)"'再打印偶数页For i = 2 To Numb Step 2.RightFooter = "".LeftFooter = "第 &P 页,共 &N 页"ActiveWindow.SelectedSheets.PrintOut From:=i, To:=iNext iEnd WithEnd Sub热心网友 时间:2023-04-29 05:07
1、第一种写法:Sub PrintRL()'代码作用:在打印EXCEL文件时连续打印奇偶页'当为奇数时页脚设在右边,为偶时设在左边并打印'By redwin for yan'2007-4-16Dim Numb As IntegerOn Error Resume Next'得到当前工作簿的打印页数NumbNumb = ExecuteExcel4Macro("Get.Document(50)")'MsgBox NumbWith ActiveSheet.PageSetupFor i = 1 To Numb Step 1If i Mod 2 = 1 Then.LeftFooter = "".RightFooter = "第 &P 页,共 &N 页"ActiveWindow.SelectedSheets.PrintOut From:=i, To:=iElse.RightFooter = "".LeftFooter = "第 &P 页,共 &N 页"ActiveWindow.SelectedSheets.PrintOut From:=i, To:=iEnd IfNext iEnd WithEnd Sub2、第二种写法:Sub PrintRL()'代码作用:在打印EXCEL文件时分开打印奇偶页'当为奇数时页码页脚设在右边,为偶时设在左边'By redwin for yan'2007-4-16Dim Numb As IntegerDim Numb1 As IntegerOn Error Resume Next'得到当前工作簿的打印页数NumbNumb = ExecuteExcel4Macro("Get.Document(50)")'MsgBox NumbWith ActiveSheet.PageSetup'先打印奇数页;考虑到放纸习惯,先设置好第一张的页码问题If Numb Mod 2 <> 1 ThenNumb1 = Numb - 1ElseNumb1 = NumbEnd IfFor i = Numb1 To 1 Step -2.LeftFooter = "".RightFooter = "第 &P 页,共 &N 页"ActiveWindow.SelectedSheets.PrintOut From:=i, To:=iNext iMsgBox "注意:奇数页已打印完毕,下面将打印偶数页,请注意放纸,确定后便开始喽!", _vbInformation, "双面打印,将节约进行到底:)"'再打印偶数页For i = 2 To Numb Step 2.RightFooter = "".LeftFooter = "第 &P 页,共 &N 页"ActiveWindow.SelectedSheets.PrintOut From:=i, To:=iNext iEnd WithEnd Sub