有大神帮忙看下,这个想用word打印自动编号合同 ,怎么搞

Phantasty. 2021-01-04 02:15:15
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

...全文
2655 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
vansoft 2021-01-15
  • 打赏
  • 举报
回复
试试自带的邮件合并功能。

1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧