自动为 ppt 文本框中的每个段落创建组合框
我是 VBa 新手,最近遇到以下问题:我将数据(行)从 excel 工作表复制到 powerpoint 中,我想为我复制的每一行(因此对于 excel 中的每一行)创建一个组合框。我所能找到的只是如何通过 Powerpoint 中的菜单手动插入组合框,但我想避免手动添加这么多组合框。有没有办法通过 VBA 代码添加组合框?
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
如何继续?想要为每个工作表行定义一个组合框
i am new to VBa and recently encountered the following problem: I copy data (rows) from an excel sheet into powerpoint and I want to make a combobox for every line (so for every row in excel) that i copy. All I could find was how to manually insert comboboxes via the menu in Powerpoint but i want to avoid having to add so many manually. Is there a way to add the comboboxes via VBA code?
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
How to continue? Want to define a combo box for each sheet row
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不清楚您发布的代码与添加组合框有什么关系,但这里有一个如何添加组合框并向其中添加项目的示例:
I'm not clear on what the code you've posted has to do with adding combo boxes, but here's an example of how to add a combo box and add items to it: