主题:偶得一打印ppt讲义页码修改程序,请高手注释一下下列VB程序
Sub HandoutNumber()
Dim i As Long
Dim lStart As Long
Dim lStop As Long
Dim lHandoutKind As Long
Dim lSlide As Long
Dim lSlideEnd As Long
Dim ppHandoutKind As PpPrintOutputType
Dim vbConfirm As VbMsgBoxResult
'
' Ask the user which slide to start printing handouts from.
'
lSlide = InputBox("Start handouts at what slide number?", _
"Starting Slide", "1")
'
' Ask the user which page number to start at.
'
lStart = InputBox("Start the page number for handouts at: ", _
"Restart Handout Page Numbers", "1")
'
' Ask the user how many slides per page they want to print.
'
lHandoutKind = InputBox("How many slides per handout page?" & _
vbNewLine & "2, 3, 4, 6, 9?", "Handout Type", "4")
'
' Use a case statement to set the handout type and the number of
' slides per page. If the user types in a number other than 2,3,
' 4,6, or 9, round up to the nearest handout layout size. If the
' number is greater than 9, make it the 9-up layout and set
' the slides per page to 9.
'
Select Case lHandoutKind
Case 1, 2
ppHandoutKind = ppPrintOutputTwoSlideHandouts
lHandoutKind = 2
Case 3
ppHandoutKind = ppPrintOutputThreeSlideHandouts
lHandoutKind = 3
Case 4
ppHandoutKind = ppPrintOutputFourSlideHandouts
lHandoutKind = 4
Case 5, 6
ppHandoutKind = ppPrintOutputSixSlideHandouts
lHandoutKind = 6
Case Else
ppHandoutKind = ppPrintOutputNineSlideHandouts
lHandoutKind = 9
End Select
'
' Confirm the settings.
'
vbConfirm = MsgBox("You have chosen to print " & lHandoutKind & _
"-up handouts, starting at page " & lStart & vbNewLine & _
" and slide number " & lSlide & ".", vbOKCancel)
'
' If the result is OK, print the range.
'
If vbConfirm = vbOK Then
'
' Calculate the number of pages that have to be printed. Then, test to
' make sure that number of pages are correct. The Round function rounds
' to the nearest whole number, therefore if you have 10 slides to print on a
' 9-up handout, lStop first is set to 1, because 10/9 = 1.1111 rounded
' to 1.
' The MOD operator returns a remainder if there are not enough slides
' to fill a page. If the remainder is less than or equal to one half of
' the layout size.
'
lStop = Round((ActivePresentation.Slides.Count - (lSlide - 1)) _
/ lHandoutKind)
If Round((ActivePresentation.Slides.Count - (lSlide - 1)) Mod _
lHandoutKind) <= (lHandoutKind / 2) Then
lStop = lStop + 1
End If
'
' From 1 to the number of pages, loop until all the pages are printed.
'
For i = 1 To lStop
'
' On the notes master, set the automatic page numbers to False; then
' insert the starting page number that the user wants. Increment the
' page number by one.
' This code assumes that object 4 on the handouts master is the page
' number footer on the handouts master page.
'
ActivePresentation.NotesMaster.HeadersFooters.SlideNumber _
.Visible = msoFalse
ActivePresentation.HandoutMaster.Shapes(4).TextFrame _
.TextRange.Text = lStart
lStart = lStart + 1
'
' Set the printer options and print the handouts.
'
With ActivePresentation.PrintOptions
'
' Set the print range type to a slide range.
'
.RangeType = ppPrintSlideRange
With .Ranges
'
' Clear any previous ranges that were set.
'
.ClearAll
'
' Set the slide range to print based on the number of slides per page.
'
lSlideEnd = lSlide + lHandoutKind - 1
'
' If the starting slide is greater than the number of slides in the
' presentation, set the value equal to that number.
' Perform the same test for lSlideEnd, to make sure the slide range
' does not exceed the number of slides in the presentation.
'
If lSlide > ActivePresentation.Slides.Count Then
lSlide = ActivePresentation.Slides.Count
End If
If lSlideEnd > ActivePresentation.Slides.Count Then
lSlideEnd = ActivePresentation.Slides.Count
End If
.Add Start:=lSlide, End:=lSlideEnd
lSlide = lSlide + lHandoutKind
End With
'
' Set number of copies to 1.
'
.NumberOfCopies = 1
'
' Set the page output to the handout layout the user has chosen.
'
.OutputType = ppHandoutKind
'
' Set the slide positioning to columns. You can also use
' ppPrintHandoutHorizontalFirst to set the slides in rows.
'
.HandoutOrder = ppPrintHandoutVerticalFirst
End With
'
' Print the single page by using the chosen settings.
'
ActivePresentation.PrintOut
Next i
End If
'
' Reset the handout master page to use automatic page numbers,
' and clear any text from the frame.
'
ActivePresentation.HandoutMaster.Shapes(4).TextFrame _
.TextRange.Text = ""
ActivePresentation.NotesMaster.HeadersFooters.SlideNumber _
.Visible = msoTrue
End Sub
我有一篇长word文档,但从55页(假设)开始插入ppt讲义文件,但默认ppt讲义文件是从1页开始的。于是在网上搜到上述可修改起始页码的宏程序,但因是新手,不太懂,而且想进一步修改为分两次打印,先打单面(比如奇数面),再打双面(偶数面),谢谢大虾先!