急急急!我想在ppt播放时能够课堂随机点名的vb代码。就是在ppt里支持的vb编程,然后界面可以在播放时显示

急急急!我想在ppt播放时能够课堂随机点名的vb代码。就是在ppt里支持的vb编程,然后界面可以在播放时显示,第1张

建个按钮建个文本框,这是宴春团晌橘随机抽取1到6学号的示森灶例

Private Sub CommandButton1_Click()

TextBox1.Text = Int((6 * Rnd) + 1)

End Sub

窗没笑拍体上放一个按钮,引用Microsoft Powerpoint 11.0 Object Library,

因为,我用的是Office2003,可能你的是其他版本,那么这里的11可能是12或其他!

代码如下,复制了就能用,但是再次提醒,要做上升哗面的引用!

Option Explicit

Private Sub Command1_Click()

Dim pptApp As PowerPoint.Application

Dim MyPresentation As Presentation

Set pptApp = CreateObject("PowerPoint.Application") '创建PowerPoint对象实例

Set MyPresentation = pptApp.Presentations.Add(True) '设置幻灯片对象创建新的幻灯片

MyPresentation.Slides.Add 1, 12 '添加一页空白幻灯片

MyPresentation.Slides(1).Shapes.AddTextbox 1, 40, 160, 650, 50 '添加1个文本框

MyPresentation.Slides(1).Shapes(1).TextFrame.TextRange.Text = "欢迎你使用VBA PowerPoint!" '在文本框里编辑文本

MyPresentation.Slides(1).Shapes(1).TextFrame.TextRange.Paragraphs(1).ParagraphFormat.Alignment = ppAlignCenter '设置文本框居中对齐

MyPresentation.Slides(1).Shapes(1).TextFrame.TextRange.Font.Name = "宋体" '设置文本框字体

MyPresentation.Slides(1).Shapes(1).TextFrame.TextRange.Font.Size = 40 '设置文本框枯羡字号

MyPresentation.Slides(1).Shapes(1).TextFrame.TextRange.Font.Color.RGB = RGB(Red:=255, Green:=0, Blue:=0) '设置文本框文字颜色

MyPresentation.SaveAs ("c:\111.ppt") '保存到文件

MyPresentation.Close '关闭幻灯片

Set MyPresentation = Nothing '释放内存空间

pptApp.Quit '关闭PowerPoint

Set pptApp = Nothing '释放内存空间

End Sub


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/12348798.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-24
下一篇 2023-05-24

发表评论

登录后才能评论

评论列表(0条)

保存