如何让WORD在打印时自动加上打印份数编号

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

如何让WORD在打印时自动加上打印份数编号

by nosper on 一月 5th, 2011

问题的提出:老婆所在的公司需要做2011年整年的文档和表格,里面的编号随着打印份数自动更新:比如需要打印100份,每份编号则按顺序从 0001排到0100。

在网上google 了一下,也有不少网友提出了类似的问题:

“公司有一份调查表,需要打印100份,每份都要有一个编号,从000001到000100。如何让WORD在打印时自动加上打印份数编号?”

这个需要用到word 的宏操作,感觉它和ps里面的action 一样,就是可以让用户自定义一些操作,让宏来重复执行。word2007 有宏录制功能(在view视窗栏里面)。

方法一:宏循环嵌套

先手动几次:改编号——打印——改下一个编号——再打印,让宏来记录这些动作。然后查看这些基本动作的宏代码,在里面加入循环和嵌套。

经过自己几次尝试和修改,得到如下宏代码:

Sub PrintCopies()

'

' Macro1 Macro

'

'

Dim i As Long

Dim lngStart

Dim lngCount

lngCount = InputBox("Please enter the number of copies you want to print", "Please enter the number of copies you want to print", 1)

If lngCount = "" Then

Exit Sub

End If

lngStart = InputBox("Enter the starting number you want to print", "Enter the starting number you want to print", 1)

If lngStart = "" Then

Exit Sub

End If

For i = lngStart To lngCount

If i < 10 Then

Selection.TypeText Text:="000" & i&

Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _

wdPrintDocumentContent, Copies:=1, Pages:="",

PageType:=wdPrintAllPages, _

ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= _

False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _

PrintZoomPaperHeight:=0

End If

If (i >= 10) And (i < 100) Then

Selection.TypeText Text:="00" & i&

Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _

wdPrintDocumentContent, Copies:=1, Pages:="",

PageType:=wdPrintAllPages, _

ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= _

False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _

PrintZoomPaperHeight:=0

End If

If (i >= 100) And (i < 1000) Then

Selection.TypeText Text:="0" & i&

Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _

wdPrintDocumentContent, Copies:=1, Pages:="",

PageType:=wdPrintAllPages, _

ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= _

False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _

PrintZoomPaperHeight:=0

End If

If (i >= 1000) And (i < 10000) Then

Selection.TypeText Text:=i

Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _

wdPrintDocumentContent, Copies:=1, Pages:="",

PageType:=wdPrintAllPages, _

ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= _

False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _

PrintZoomPaperHeight:=0

End If

Selection.TypeBackspace

Selection.TypeBackspace

Selection.TypeBackspace

Selection.TypeBackspace

Next

End Sub

执行以上代码可以最大从0001份打印到9999份,并会在光标处自动加上打印份数编号。如第10份则会在光标处插入打印份数编号0010.

也可通过修改以上代码实现更大数目的打印量:添加并修改相应的 if 语句。

以上宏代码的安装:

相关文档
最新文档