【问题标题】:Why won't my slide print为什么我的幻灯片打印不出来
【发布时间】:2014-03-19 12:27:26
【问题描述】:

我为我的计算机课程创建了我的第一个 VBA 测验,​​并且需要打印结果。在与我在网上找到的几个模型进行比较后,我粘贴了 PrintablePage 和 PrintResults。请告诉我哪里出错了。结果页面立即出现,但打印按钮不起作用。

Sub PrintablePage()
Dim printableSlide As Slide
Dim printbutton As Shape
Dim donebutton As Shape

Set printableSlide = ActivePresentation.Slides.Add(Index:=8, Layout:=ppLayoutText)
printableSlide.Shapes(1).TextFrame.TextRange.Text = "Test results for " & Username
printableSlide.Shapes(2).TextFrame.TextRange.Text = "You got " & numberRight & " out of " & _
numberRight + numberWrong & "." & Chr$(13) & "Please press print."

Set donebutton = ActivePresentation.Slides(8).Shapes.AddShape(msoShapeActionButtonCustom, 0, 0, 150, 50)
donebutton.TextFrame.TextRange.Text = "Close Program"
donebutton.ActionSettings(ppMouseClick).Action = ppActionRunMacro
donebutton.ActionSettings(ppMouseClick).Run = "done"

Set printbutton = ActivePresentation.Slides(8).Shapes(2).AddShape(msoShapeActionButtonCustom, 400, 400, 100, 100)
printbutton.TextFrame.TextRange.Text = "Print"
printbutton.ActionSettings(ppMouseClick).Action = ppActionRunMacro
printbutton.ActionSettings(ppMouseClick).Run = "PrintResults"
ActivePresentation.SlideShowWindow.View.Next
ActivePresentation.Saved = True
End Sub

Sub PrintResults()
donebutton.Visible = False
printbutton.Visible = False
ActivePresentation.PrintOptions.OutputType = ppPrintOutputSlides
ActivePresentation.PrintOut From:=8, To:=8
donebutton.Visible = True
printbutton.Visible = True
End Sub

Sub done()
MsgBox "The program will shut down now"
ActivePresentation.Slides(8).Delete
ActivePresentation.Saved = msoCTrue
ActivePresentation.Application.Quit
End Sub

任何帮助将不胜感激。

【问题讨论】:

  • 我什至不知道那个 2 来自哪里,可能是因为我已经尝试了我能找到的每一个。反正我不
  • @portlandrunner 感谢您的帮助。我什至不知道那个 2 来自哪里,可能是因为我已经尝试了我能找到的每一个。无论如何,我没有 2,它仍然不会打印。带有结果的可打印页面,没问题。关闭时删除结果页面,没问题。但是打印......没有任何效果。我比较的每个样本都是相同的,当然除了幻灯片索引。这既令人沮丧又令人兴奋,对我来说就像一个很好的谜!

标签: vba printing powerpoint


【解决方案1】:

您正在尝试将形状添加到现有索引。 PowerPoint 不允许这样做。

变化:

Set printbutton = ActivePresentation.Slides(8).Shapes(2).AddShape(msoShapeActionButtonCustom, 400, 400, 100, 100)

收件人:

Set printbutton = ActivePresentation.Slides(8).Shapes.AddShape(msoShapeActionButtonCustom, 400, 400, 100, 100)

如果您在键入时使用智能感知,您会注意到,如果您将索引添加到 Shapes(2),那么 AddShape 不是一个选项,但如果您只使用 Shapes.,那么 AddShape 是一个有效的方法。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-10
    • 2015-01-27
    • 2019-03-17
    相关资源
    最近更新 更多