我试图创建这个脚本,创建10个空幻灯片,但由于某些原因它不起作用:
Sub CreatingSlides()
Dim oPresentation As Presentation
Set oPresentation = ActivePresentation
Dim oSlide As Slide
Dim oSlides As SlideRange
Dim oShape As Shape
Dim slideNumber As Integer
Dim myindex As Integer
Set myindex = 1
ActivePresentation.Slides.add(Index:=myindex, Layout:=ppLayoutBlank).Select
For myindex = 1 To 10
myindex = myindex + 1
ActivePresentation.Slides.add(Index:=myindex, Layout:=ppLayoutBlank).Select
Next myindex
End Sub
Run Code Online (Sandbox Code Playgroud)
我在这做错了什么?也许我的循环在这里缺少一些东西?
我正在尝试调整使用powerpoint vba从Excel粘贴到powerpoint中的图片的大小。
我的代码说:
ActivePresentation.Slides(9).Select
Application.ActiveWindow.View.PasteSpecial DataType:=ppPasteEnhancedMetafile
这部分工作正常,我不知如何在下一步中调整图片的大小。我是使用Powerpoint VBA的新手。
任何帮助将非常感激。
此代码捕获活动窗口并将其粘贴到功率点幻灯片上,方法是通过调用a来粘贴数字屏幕截图sub PrintScreen,之后需要5秒钟来捕获活动窗口的屏幕.虽然我希望每当我按下像'F7或F3等'的特定键时,它应该采用打印屏幕而不是等待5秒钟.我只想按下键并调用sub,其中我指定了打印和粘贴以及其他功能.
Sub Screen_Capture_VBA()
Dim Sec4 As Date
MsgBox "Note: Three seconds after you click OK " & _
"the active window will be copied to the clipboard."
Sec4 = DateAdd("s", 4, Now)
myValue = InputBox("Give me no of screen shots you want to capture")
For I = 1 To myValue
PrintScreen
Next I
End Sub
Run Code Online (Sandbox Code Playgroud)
这是我的打印屏幕子.
Sub PrintScreen()
Sleep 5000
keybd_event VK_MENU, 0, 0, 0
keybd_event VK_SNAPSHOT, 0, 0, 0
keybd_event VK_SNAPSHOT, 0, KEYEVENTF_KEYUP, 0
keybd_event VK_MENU, …Run Code Online (Sandbox Code Playgroud) 我试图从Excel自动化PowerPoint.一切都很好.我有以下代码块完美地工作:
Set MyTextbox = mySlide.Shapes.AddTextbox(1, Left:=myShape.Left - 3, Top:=42, Width:=myShape.Width + 6, Height:=10).TextFrame.TextRange
With MyTextbox
.Text = Format(MyShapeDate, "m/yy")
.Font.Size = 11
.ParagraphFormat.Alignment = ppAlignCenter
.Font.Bold = True
End With
Run Code Online (Sandbox Code Playgroud)
我将代码保存为插件并尝试添加新选项卡和按钮,但未成功.所以我把代码带回了工作簿.当我试图再次运行它时,我得到一个未定义的变量ppAlignCenter.有谁知道为什么会发生这种情况或是否是常见错误?
如果我有一个.ppt幻灯片,我想从中提取信息,我为各个人在整个组织中使用的所有幻灯片设置模板,并且我知道每个文本框对象的所有"名称",
我可以使用一些vb将这些信息从.ppt幻灯片中提取到访问数据库中吗?
我知道如何获取访问表单并以相同的方式创建输入信息的ppt演示文稿,只需要反向过程.所以我假设如果我设置这些ppt幻灯片,并将所有文本框命名为我想要命名的那些,我应该能够在相反的方向上做到这一点,对吧?
我有一个包含200多个Powerpoint文件的文件夹,我一直在努力使用宏打开每个文件,编辑它们,保存它们并在循环中关闭它们.我已经设法为编辑部分创建代码,但是我无法创建一个代码来选择文件夹中的每个文件.使用"*.pptx"似乎不起作用,为每个文件编写具有特定文件名的代码效率非常低.
有人有解决方案吗?
Sub SaveNotesText()
Dim oPres As Presentation
Dim oSlides As Slides
Dim oSlide As Slide
Dim oShapes As Shapes
Dim oSh As Shape
Dim NotesText As String
Dim FileNum As Integer
Dim PathSep As String
#If Mac Then
PathSep = ":"
#Else
PathSep = "\"
#End If
Set oPres = ActivePresentation
Set oSlides = oPres.Slides
For Each oSlide In oSlides
NotesText = NotesText & "Slide " & oSlide.SlideIndex & vbCrLf
Set oShapes = oSlide.NotesPage.Shapes
For Each oSh …Run Code Online (Sandbox Code Playgroud) 我需要知道如何在演示期间禁用键盘,因为我真的不希望人们跳过PowerPoint而是与之交互.我只想禁用让人们在箭头键和空格键等幻灯片周围移动的按钮.
我有一个代码将我指定的幻灯片保存为PNG:
Dim userName As String
userName = Slide322.TextBox1.Text
'Save slide
ActivePresentation.Slides(302).Export _
filename:="C:\Users\Jessica\Dropbox\Uni\DISSERTATION\Questionnaire\Tools\Results\" & userName & ".png", FilterName:="PNG"
Run Code Online (Sandbox Code Playgroud)
但是,我想将幻灯片保存为.PPT,以便我可以在以后打开它并编辑该幻灯片上的文本.我尝试过使用.SaveAs语法,但每次都会收到一条错误消息,它不会识别任何"保存"类型的表达式.
我搜索过,并搜索了这个答案......有人可以帮忙吗?
我必须将大量Excel图表发布到特定的PowerPoint文档中,然后在Excel VBA中构建一个宏来为我完成.
我能够正确地打开我想要更新的PowerPoint演示文稿,但是我不知道如何设置我刚刚打开的演示文稿到一个名为的变量MyPresentation.
Dim myPresentation As PowerPoint.Presentation
Dim PowerPointApp As PowerPoint.Application
PowerPointApp.Presentations.Open Filename:="obscured filepath and name"`
Run Code Online (Sandbox Code Playgroud)
显然还有一些额外的代码,但我正在尝试将我刚刚在第3行设置的Presentation设置为MyPresentation变量,这样我就可以引用刚刚打开的文档了.
我正在浏览Powerpoint幻灯片1中的形状
当名称为“ HD”的形状被删除时,下一个形状将变为“ SD”,跳过“ 4K”。如果删除了“ 4K”,则下一个形状变为“ FullHD”
如何避免这种情况?
For Each pshape In ppres.Slides(1).Shapes
Select Case pshape.Name
Case "HD"
Debug.Print vbTab & pshape.Name
If LCase(Cells(2, titleHeader.ListColumns("Nature of Material*").Index)) <> "hd" And LCase(Cells(2, titleHeader.ListColumns("Nature of Material*").Index)) = "" Then
pshape.Delete
End If
Case "4K"
Debug.Print vbTab & pshape.Name
If LCase(Cells(2, titleHeader.ListColumns("Nature of Material*").Index)) <> "4k" And LCase(Cells(2, titleHeader.ListColumns("Nature of Material*").Index)) = "" Then
pshape.Delete
End If
Case "SD"
Debug.Print vbTab & pshape.Name
Case "FullHD"
Debug.Print vbTab & pshape.Name
Debug.Print vbTab & Cells(2, …Run Code Online (Sandbox Code Playgroud) powerpoint-vba ×10
powerpoint ×7
vba ×7
excel ×3
excel-vba ×2
action ×1
batch-file ×1
keyboard ×1
ms-access ×1
save ×1