从XL中取代PPT

时间:2011-12-14 15:06:54

标签: excel-vba powerpoint-vba vba excel

我正在尝试用XL创建一些幻灯片,但是受到脚注的挑战。 我想要的是用多个脚注填充脚注部分,而每行以一个上标的数字开头。谁能告诉我怎么做到这一点?

我尝试了一些我在网上找到的解决方案,但我不能只标注一个字符。

感谢您的帮助

s

1 个答案:

答案 0 :(得分:0)

这样的事情应该让你开始;编写的代码是用PPT运行的,需要一些mod才能在Excel中运行它:

Dim oSl As Slide
Dim oSh As Shape
Dim oPres As Presentation
Dim x As Long

' for example purposes, we'll do this IN PPT
' and use the current presentation
Set oPres = ActivePresentation

' and we'll work with slide 1
Set oSl = oPres.Slides(1)

' rather than using PPT's own footnotes, I'd simply
' add my own text box ...
Set oSh = oSl.Shapes.AddTextbox(msoTextOrientationHorizontal, 10, 500, 500, 50)

' and work with it ...
With oSh
    ' add your text:
    .TextFrame.TextRange = "1One line of text" & vbCrLf _
        & "2Two lines of text, the second a bit longer" & vbCrLf _
        & "3New we are three lines of text"

    ' subscript the first character of each line up to 9
    On Error Resume Next    ' in case there are fewer lines
    For x = 1 To 9
        .TextFrame.TextRange.Paragraphs(x).Characters(1, 1).Font.Superscript = True
    Next
    ' and the first two characters of each line past that
    For x = 10 To .TextFrame.TextRange.Paragraphs.Count
        .TextFrame.TextRange.Paragraphs(x).Characters(1, 2).Font.Superscript = True
    Next
End With