首页 文章

Powerpoint VBA粗体字体

提问于
浏览
0

我创建了一个多项选择测试(使用VBA)与训练模块一起使用 . 两者都是在PowerPoint 2013中创建的 . 在测试结束时,有一个页面将打印出结果和学生参加测试时给出的答案 . 我遇到的问题是:我需要以某种方式区分错误答案和正确答案 . 我想让结果页面上显示的错误答案的字体变为粗体,我无法弄清楚如何做到这一点 . 我通过互联网上的搜索找不到VBA和我所做的大部分工作 . 这是我所拥有的VBA的“错误答案”部分:

Sub WrongAnswer()

    Dim thisQuestionNum As Long

    thisQuestionNum = _
        ActivePresentation.SlideShowWindow.View.Slide.SlideIndex - 1
    If qAnswered(thisQuestionNum) = False Then
        numIncorrect = numIncorrect + 1
    End If
    qAnswered(thisQuestionNum) = True
    MsgBox "Incorrect. "
    ActivePresentation.SlideShowWindow.View.Next
End Sub

基本上它的作用是告诉学生他们点击的按钮是否正确或不正确,然后将答案和数字正确/不正确地存储到可打印的幻灯片中 . 我是否需要创建一个全新的子部分才能使字体显示为粗体?或者我可以将它添加到我的错误答案部分吗?我需要什么代码才能使其正常工作?

1 回答

  • 0

    引用了第一栏文本的相关部分;同样的更改也适用于第二列:

    Dim oRng as TextRange

    For i = 1 To 24 
    
    ' Instead of this:
        printableSlide.Shapes(2).TextFrame.TextRange.Text = _ printableSlide.Shapes(2).TextFrame.TextRange.Text & _ "Question " & i & ": " & answer(i) & Chr$(13) 
    
    ' Do this:
    ' This just adds the answer, to keep it simple to understand for now. 
    ' You can add the "Question: " stuff later:
    Set oRng = printableSlide.Shapes(2).TextFrame.TextRange.InsertAfter (vbcrlf & answer(1))
    With oRng
       .Font.Size = 9
       .Font.Bold = True
        ' etc
    End with
    Next i 
    
    printableSlide.Shapes(2).TextFrame.TextRange.Font.Size = 9
    

相关问题