|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
求高手帮助,这个vb怎么回事,打印序号只能从1开始,不能从其他数字开始。比如我想从51开始就打印不了,求大侠帮助!
Sub 合同打印5()
Dim lngStart
Dim lngCount
Dim i As Integer
lngStart = InputBox("请录入合同开始序列号", "请录入合同开始序列号", 1)
If lngStart = "" Then
Exit Sub
End If
lngCount = InputBox("请录入打印合同份数", "请录入打印合同份数", 1)
If lngCount = "" Then
Exit Sub
End If
Selection.Find.ClearFormatting
With Selection.Find
.Text = "合同编号:"
.Wrap = wdFindContinue
End With
Selection.Find.Execute
For i = lngStart To lngCount
If i < 10 Then
Selection.HomeKey unit:=wdLine
Selection.EndKey unit:=wdLine, Extend:=wdExtend
Selection.TypeText Text:="合同编号:S201607000" & i
ActiveDocument.PrintOut
End If
If i >= 10 And i < 100 Then
Selection.HomeKey unit:=wdLine
Selection.EndKey unit:=wdLine, Extend:=wdExtend
Selection.TypeText Text:="合同编号:S20160700" & i
ActiveDocument.PrintOut
End If
If i >= 100 And i < 1000 Then
Selection.HomeKey unit:=wdLine
Selection.EndKey unit:=wdLine, Extend:=wdExtend
Selection.TypeText Text:="合同编号:S2016070" & i
ActiveDocument.PrintOut
End If
Next i
End Sub
|
|