Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 2236|回复: 7

[已解决]请大家帮我精简优化下这二组代码。谢谢大家了!

[复制链接]
发表于 2013-12-5 11:23 | 显示全部楼层 |阅读模式
本帖最后由 yjwdjfqb 于 2013-12-5 11:24 编辑

  1. Sub Ⅰ反打偶数页()  '正反面打印,先反打偶数页,打印完后确定,再顺打奇数页
  2.     With Options
  3.         .UpdateFieldsAtPrint = False
  4.         .UpdateLinksAtPrint = False
  5.         .DefaultTray = "使用打印机设置"
  6.         .PrintBackground = True
  7.         .PrintProperties = False
  8.         .PrintFieldCodes = False
  9.         .PrintComments = False
  10.         .PrintHiddenText = False
  11.         .PrintXMLTag = False
  12.         .PrintDrawingObjects = True
  13.         .PrintDraft = False
  14.         .PrintReverse = True
  15.         .MapPaperSize = True
  16.         .PrintOddPagesInAscendingOrder = False
  17.         .PrintEvenPagesInAscendingOrder = False
  18.         .PrintBackgrounds = False
  19.     End With
  20.     With ActiveDocument
  21.         .PrintPostScriptOverText = False
  22.         .PrintFormsData = False
  23.     End With
  24.     Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
  25.                                                                         wdPrintDocumentContent, Copies:=1, Pages:="", PageType:= _
  26.                                                                                                                                 wdPrintEvenPagesOnly, ManualDuplexPrint:=False, Collate:=True, Background _
  27.                                                                                                                                                                                                :=True, PrintToFile:=False, PrintZoomColumn:=0, PrintZoomRow:=0, _
  28.                          PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0
  29. MsgBox "反顺打印偶数页完成,请换打印纸方向,正顺打印奇数页!"
  30. End Sub
  31. Sub Ⅱ正打奇数页()  '正反面打印,先反打偶数页,打印完后确定,再顺打奇数页
  32.     With Options
  33.         .UpdateFieldsAtPrint = False
  34.         .UpdateLinksAtPrint = False
  35.         .DefaultTray = "使用打印机设置"
  36.         .PrintBackground = True
  37.         .PrintProperties = False
  38.         .PrintFieldCodes = False
  39.         .PrintComments = False
  40.         .PrintHiddenText = False
  41.         .PrintXMLTag = False
  42.         .PrintDrawingObjects = True
  43.         .PrintDraft = False
  44.         .PrintReverse = False
  45.         .MapPaperSize = True
  46.         .PrintOddPagesInAscendingOrder = False
  47.         .PrintEvenPagesInAscendingOrder = False
  48.         .PrintBackgrounds = False
  49.     End With
  50.     With ActiveDocument
  51.         .PrintPostScriptOverText = False
  52.         .PrintFormsData = False
  53.     End With
  54.     Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
  55.                                                                         wdPrintDocumentContent, Copies:=1, Pages:="", PageType:= _
  56.                                                                                                                                 wdPrintOddPagesOnly, ManualDuplexPrint:=False, Collate:=True, Background _
  57.                                                                                                                                                                                               :=True, PrintToFile:=False, PrintZoomColumn:=0, PrintZoomRow:=0, _
  58.                          PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0
  59. End Sub
  60. '请大家帮我精简优化下这二组代码。谢谢大家了!
复制代码
最佳答案
2013-12-5 12:00
  1. Sub Ⅰ反打偶数页()  '正反面打印,先反打偶数页,打印完后确定,再顺打奇数页
  2.     With Options
  3.         .DefaultTray = "使用打印机设置"
  4.         .PrintBackground = True
  5.         .PrintDrawingObjects = True
  6.         .PrintReverse = True
  7.         .MapPaperSize = True
  8.     End With
  9.     Application.PrintOut Filename:="", Range:=wdPrintAllDocument, Item:= _
  10.                          wdPrintDocumentContent, Copies:=1, Pages:="", PageType:= _
  11.                          wdPrintEvenPagesOnly, Collate:=True, Background:=True

  12.     MsgBox "反顺打印偶数页完成,请换打印纸方向,正顺打印奇数页!"
  13. End Sub
  14. Sub Ⅱ正打奇数页()  '正反面打印,先反打偶数页,打印完后确定,再顺打奇数页
  15.     With Options
  16.         .DefaultTray = "使用打印机设置"
  17.         .PrintBackground = True
  18.         .PrintDrawingObjects = True
  19.         .MapPaperSize = True

  20.     End With
  21.     Application.PrintOut Filename:="", Range:=wdPrintAllDocument, Item:= _
  22.                          wdPrintDocumentContent, Copies:=1, Pages:="", PageType:= _
  23.                          wdPrintOddPagesOnly, ManualDuplexPrint:=False, Collate:=True, Background:=True

  24. End Sub
  25. '请大家帮我精简优化下这二组代码。谢谢大家了!
复制代码
没测试,楼主自己测下。
excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
 楼主| 发表于 2013-12-5 11:24 | 显示全部楼层
请大家帮帮我精简优化下上面的二组代码, 谢谢大家了
回复

使用道具 举报

发表于 2013-12-5 12:00 | 显示全部楼层    本楼为最佳答案   
  1. Sub Ⅰ反打偶数页()  '正反面打印,先反打偶数页,打印完后确定,再顺打奇数页
  2.     With Options
  3.         .DefaultTray = "使用打印机设置"
  4.         .PrintBackground = True
  5.         .PrintDrawingObjects = True
  6.         .PrintReverse = True
  7.         .MapPaperSize = True
  8.     End With
  9.     Application.PrintOut Filename:="", Range:=wdPrintAllDocument, Item:= _
  10.                          wdPrintDocumentContent, Copies:=1, Pages:="", PageType:= _
  11.                          wdPrintEvenPagesOnly, Collate:=True, Background:=True

  12.     MsgBox "反顺打印偶数页完成,请换打印纸方向,正顺打印奇数页!"
  13. End Sub
  14. Sub Ⅱ正打奇数页()  '正反面打印,先反打偶数页,打印完后确定,再顺打奇数页
  15.     With Options
  16.         .DefaultTray = "使用打印机设置"
  17.         .PrintBackground = True
  18.         .PrintDrawingObjects = True
  19.         .MapPaperSize = True

  20.     End With
  21.     Application.PrintOut Filename:="", Range:=wdPrintAllDocument, Item:= _
  22.                          wdPrintDocumentContent, Copies:=1, Pages:="", PageType:= _
  23.                          wdPrintOddPagesOnly, ManualDuplexPrint:=False, Collate:=True, Background:=True

  24. End Sub
  25. '请大家帮我精简优化下这二组代码。谢谢大家了!
复制代码
没测试,楼主自己测下。
回复

使用道具 举报

 楼主| 发表于 2013-12-5 12:17 | 显示全部楼层
hwc2ycy 发表于 2013-12-5 12:00
没测试,楼主自己测下。

反打偶数页正确

但是正打奇数页,成了,反打了奇数页。 改成:正顺打印奇数页
回复

使用道具 举报

发表于 2013-12-5 12:40 | 显示全部楼层
yjwdjfqb 发表于 2013-12-5 12:17
反打偶数页正确

但是正打奇数页,成了,反打了奇数页。 改成:正顺打印奇数页
  1. Sub Ⅱ正打奇数页()  '正反面打印,先反打偶数页,打印完后确定,再顺打奇数页
  2.     With Options
  3.         .PrintBackground = True
  4.         .PrintDrawingObjects = True
  5.         .MapPaperSize = True
  6.         .PrintOddPagesInAscendingOrder = False
  7.         .PrintEvenPagesInAscendingOrder = False
  8.         .PrintBackgrounds = False
  9.     End With
  10.     Application.PrintOut Filename:="", Range:=wdPrintAllDocument, Item:= _
  11.                                                                         wdPrintDocumentContent, Copies:=1, Pages:="", PageType:= _
  12.                                                                                                                                 wdPrintOddPagesOnly, ManualDuplexPrint:=False, Collate:=True, Background _
  13.                                                                                                                                                                                               :=True, PrintToFile:=False, PrintZoomColumn:=0, PrintZoomRow:=0, _
  14.                          PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0
  15. End Sub
复制代码
回复

使用道具 举报

 楼主| 发表于 2013-12-5 14:16 | 显示全部楼层
hwc2ycy 发表于 2013-12-5 12:00
没测试,楼主自己测下。

谢谢版主的帮助,问题解决了!
回复

使用道具 举报

发表于 2013-12-5 14:19 | 显示全部楼层
yjwdjfqb 发表于 2013-12-5 14:16
谢谢版主的帮助,问题解决了!

一般情况下,属性的默认属性是FALSE,刚刚有两个设置单页的没注意直接干掉,就成了TRUE了。


回复

使用道具 举报

 楼主| 发表于 2013-12-5 14:21 | 显示全部楼层
hwc2ycy 发表于 2013-12-5 14:19
一般情况下,属性的默认属性是FALSE,刚刚有两个设置单页的没注意直接干掉,就成了TRUE了。

就是,把属性改一下,参照老师的改了下,就对了。谢谢老师!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-4-20 18:49 , Processed in 0.422099 second(s), 8 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表