ppt 解决幻灯片打印讲义从页码1开始的方法
相信很多朋友在打印ppt时都遇到过,打印讲义只能从页码1开始,有时有好几个幻灯片打印,希望页码顺序能够相连;或者打印一套幻灯片的时候,中间卡纸了,在重新打印的时候,出来的页面还是页码1。
找遍了网上相关的解决方法,很多人都提出这个问题,但是真正解决的还没有。
下面就列出一个利用VBA宏的方法来搞定他吧
| 1. | 在 工具 菜单上, 指向 宏 , 然后单击 " VisualBasic 编辑器 。 |
| 2. | 在 插入 菜单上, 单击 模块 。 |
| 3. | 模块中键入如下代码: |
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 = msoTrueEnd Sub

最新评论