|
本帖最后由 xp2001 于 2015-6-10 13:46 编辑
For i = Ps To 1 Step -1 ’倒序打印
ActiveDocument.ActiveWindow.PrintOut Range:=wdPrintFromTo, From:="1", To:="3"
‘这一句可以实现打印第1-3页
ActiveDocument.ActiveWindow.PrintOut Range:=wdPrintFromTo, From:=CVar(i), To:=CVar(i)
这一句老是说“类型不匹配”,实在已经将变量i转变为Variant类型了
Next i
请大家指点一二,谢谢
'-------------------------------已经完美解决,涉及到printout 相关参数引用变量的问题,这个引用方式有点怪而已,方法如下:ActiveDocument.ActiveWindow.PrintOut Range:=wdPrintFromTo, From:="" & i, To:="" & i 这样引用即可
ex:
Sub 逆序号页打印奇数页()
Dim i%, Ps%, a%
Dim page() As Integer
Dim pages As String
Ps = ActiveDocument.BuiltInDocumentProperties(wdPropertyPages) '总页数
ReDim page(Ps)
a = Ps Mod 2
If a = 0 Then '如果ps为偶数
For i = Ps - 1 To 1 Step -2 '从倒手第二页开始打印
page(i) = i
pages = pages + "," + CStr(page(i))
Next i
Else
For i = Ps - 2 To 1 Step -2 '如果是奇数,从倒手第二页开始
page(i) = i
pages = pages + "," + CStr(page(i))
Next i
pages = pages + "," + CStr(Ps) '把第最后一页奇数页单独打出来,以免打印反面时,最后一页本该“单”着的,搞得把第1页“单”着了,所以把这页单独打印后拿出来再打反面
End If
pages = Right(pages, Len(pages) - 1)
ActiveDocument.ActiveWindow.PrintOut Range:=wdPrintRangeOfPages, pages:="" & pages
End Sub
'------------------------------------
Sub 逆序页打印偶数页()
Dim i%, Ps%, a%
Dim page() As Integer
Dim pages As String
Ps = ActiveDocument.BuiltInDocumentProperties(wdPropertyPages) '总页数
ReDim page(Ps)
a = Ps Mod 2
If a = 0 Then '如果ps为偶数
For i = Ps To 1 Step -2 '从倒手第1页开始打印
page(i) = i
pages = pages + "," + CStr(page(i))
Next i
Else
For i = Ps - 1 To 1 Step -2 '如果是奇数,从倒手第2页开始
page(i) = i
pages = pages + "," + CStr(page(i))
Next i
End If
pages = Right(pages, Len(pages) - 1)
ActiveDocument.ActiveWindow.PrintOut Range:=wdPrintRangeOfPages, pages:="" & pages
End Sub
|
|