让WORD在打印时自动加上打印份数编号
1、第一步首先找到Word里的宏按钮,如图然后,会弹出宏查看窗口,起一个名字然后选择创建,如图
2、第二步在弹出的宏录制窗口内输入宏代码,然后保存,如图宏代码如下:Sub PrintCopies()‘‘ Ma艘早祓胂cro1 Macro‘‘Dim i As LongDim lngStartDim lngCountlngCount = InputBox(“Please enter the number of copies you want to print”, “Please enter the number of copies you want to print”, 1)If lngCount = “” ThenExit SubEnd IflngStart = InputBox(“Enter the starting number you want to print”, “Enter the starting number you want to print”, 1)If lngStart = “” ThenExit SubEnd IfFor i = lngStart To lngCountIf i < 10 ThenSelection.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:=0End IfIf (i >= 10) And (i < 100) ThenSelection.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:=0End IfIf (i >= 100) And (i < 1000) ThenSelection.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:=0End IfIf (i >= 1000) And (i < 10000) ThenSelection.TypeText Text:=iApplication.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:=0End IfSelection.TypeBackspaceSelection.TypeBackspaceSelection.TypeBackspaceSelection.TypeBackspaceNextEnd Sub
3、第三步把输入光标放在你想要添加打印份数编号的地方,然后运行宏,会弹出如下窗口,第一个窗口是输入打印份数,第二个窗口是输入起始数字,如图