2011-08-02 55 views
0

我是新來的VBA和最近遇到了以下問題:我從一個Excel工作表到PowerPoint中複製數據(行),我想打一個組合框的每一行(所以對於每排在Excel中),我複製。所有我能找到的是如何通過Powerpoint中的菜單手動插入組合框,但我想避免手動添加這麼多。有沒有辦法通過VBA代碼添加組合框?在PPT文本每個段落會自動創建組合框

Here is some of the code I use: 

'Loop through each worksheet 
For Each objSheet In ActiveWorkbook.Worksheets 

'Create new slide for the data 
Set pptSld = pptPre.Slides.Add(Index:=pptPre.Slides.count + 1, Layout:=ppLayoutText) 

'Paste the data to the text box of each slide 
objSheet.UsedRange.Copy 
pptSld.Shapes(2).TextFrame.TextRange.Paste 

'Formatting the text box 2 
pptSld.Shapes(2).TextFrame.TextRange.ParagraphFormat.Bullet = msoTrue 
pptSld.Shapes(2).TextFrame.TextRange.ParagraphFormat.Bullet.RelativeSize = 1 
pptSld.Shapes(2).TextFrame.TextRange.Font.Size = 16 

    Next objSheet 

如何繼續?要定義一個組合框爲每個錶行

回答

0

我不是什麼你已經發布的代碼與添加組合框做的,但在這裏清楚是如何添加一個組合框和添加項目爲例它:

Dim oSh As Shape 
Dim oSl As Slide 
Set oSl = ActivePresentation.Slides(1) 

Set oSh = oSl.Shapes.AddOLEObject(Left:=168, Top:=24, Width:=192, Height:=24, ClassName:="Forms.ComboBox.1", Link:=msoFalse) 
With oSh.OLEFormat.Object 
    .AddItem ("This") 
    .AddItem ("That") 
    .AddItem ("The Other") 
End With