2014-03-19 2 views
0

내 컴퓨터 클래스에 대한 첫 번째 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 

도움이 되셨다면 도움이 될 것입니다.

+0

저는 2 명이 어디서 왔는지조차 알지 못합니다. 아마도 내가 찾은 모든 것을 시도했기 때문일 것입니다. 어쨌든, 나는 돈을 – Bernadette

+0

@portlandrunner 도와 주셔서 감사합니다. 나는 2가 어디에서 왔는지조차 알지 못합니다. 아마 내가 찾을 수있는 모든 것을 시도했기 때문일 것입니다. 어쨌든, 나는 2를 가지고 있지 않으며 여전히 인쇄하지 않을 것입니다. 인쇄 결과 페이지, 문제 없음. 종료시 결과 페이지 삭제, 문제 없음. 그러나 인쇄 ... 아무것도 작동하지 않습니다. 내가 비교하는 모든 샘플은 슬라이드 인덱스를 제외하고는 동일합니다. 이것은 너무 초조해하면서도 흥미로 우며, 그것은 나에게 좋은 신비와도 같습니다! – Bernadette

답변

1

기존 인덱스에 셰이프를 추가하려고합니다. PowerPoint는 이것을 허용하지 않습니다.

변경 :

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

사람 : 당신은 당신이 Shapes(2)에 인덱스를 추가하는 경우 다음 AddShape이 옵션을 선택하지 않습니다 것을 알 수 있습니다 입력하는 동안

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

당신은 IntelliSense를 사용하는 경우 만 Shapes. 만 사용하는 경우 AddShape은 유효한 방법입니다.

관련 문제