列出选定的幻灯片索引号

Listing the selected slide index numbers

我有一个大型演示文稿,我正在寻找 select 多个位于不同位置的幻灯片,并收到幻灯片索引号列表。我的想法是让这个列表出现在消息框中。

到目前为止,我已经整理了下面的内容,它在不同的消息框中为我提供了每张幻灯片的编号。我正在寻找显示在 1 个消息框中的列表,我可以将其复制并粘贴到电子邮件中。

理想情况下,我想在消息框中添加一些额外的文本,以便我可以复制并粘贴到预先制作的电子邮件中。不过我可能可以接下那部分。

如有任何帮助,我们将不胜感激。

Sub ShowMeSlideNumbers()

Dim oSld As Slide

For Each oSld In ActiveWindow.Selection.SlideRange

MsgBox "The slide index of the current slide is:" & oSld.SlideIndex

Next oSld

Exit Sub

End Sub

您可以通过创建一个数组来存储选定的索引号来完成此操作。然后以相反的顺序读回数组编号以创建一个字符串。最后,将该字符串显示为 MsgBox 的一部分:

Sub ShowMeSlideNumbers()
    Dim oSld As Slide
    Dim X As Integer, Y As Integer, arrSlideNumbers() As Integer
    Dim strSlideNumbers As String
    
    X = 0
    
    For Each oSld In ActiveWindow.Selection.SlideRange
        ReDim Preserve arrSlideNumbers(X)
        arrSlideNumbers(X) = oSld.SlideIndex
        X = X + 1
    Next oSld
    For Y = UBound(arrSlideNumbers) To 2 Step -1
        strSlideNumbers = strSlideNumbers & CStr(arrSlideNumbers(Y)) & ", "
    Next Y
    strSlideNumbers = strSlideNumbers & CStr(arrSlideNumbers(1)) & " and "
    strSlideNumbers = strSlideNumbers & CStr(arrSlideNumbers(0))
    MsgBox "The slide indices of the selected slides are: " & strSlideNumbers & "."
End Sub

一个简单的 mod 您现有的代码应该可以做到:

Sub ShowMeSlideNumbers()

Dim oSld As Slide
Dim sTemp as string

For Each oSld In ActiveWindow.Selection.SlideRange

sTemp = sTemp & "The slide index of the current slide is:" & oSld.SlideIndex & VbCRLF

Next oSld

MsgBox sTemp

End Sub