【发布时间】:2021-02-04 08:23:23
【问题描述】:
我是新来的,希望得到您的帮助。 我有一个用于 PowerPoint 的宏加载项在旧版本中运行良好。 新的 365 办公室没有运行它;通过一些技巧,我能够解决大部分问题。 现在唯一剩下的就是当尝试打开并从文件夹中选择图像文件时,它会将图像名称加载到每张幻灯片中,而不是图像!
Sub Insert1PicViaForm()
' Added on 21.05.06 to load single file using code from
'
' http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnovba00/html/CommonDialogsPartI.asp
'
'
Dim OFN As OPENFILENAME
Dim Ret
Dim N As Integer
Dim ddd
Dim oSld As Slide
Dim oPic As Shape
With OFN
.lStructSize = LenB(OFN) ' Size of structure.
.nMaxFile = 574 ' Size of buffer.
' Create buffer.
.lpstrFile = String(.nMaxFile - 1, 0)
Ret = GetOpenFileName(OFN) ' Call function.
If Ret <> 0 Then ' Non-zero is success.
' Find first null char.
N = InStr(.lpstrFile, vbNullChar)
' Return what's before it.
' MsgBox Left(.lpstrFile, n - 1)
' Full path and filename
ddd = Left(.lpstrFile, N - 1)
' Add slide at end of presentation
Set oSld = ActivePresentation.Slides.Add(ActivePresentation.Slides.count + 1, ppLayoutBlank)
' Insert pic as selected
Set oPic = oSld.Shapes.AddPicture(FileName:=ddd, _
LinkToFile:=msoCTrue, _
SaveWithDocument:=msoCTrue, _
Left:=60, _
Top:=35, _
Width:=98, _
Height:=48)
End If
End With
End Sub
【问题讨论】:
-
请edit您的问题并直接添加代码,而不是在图像中
-
感谢 Ricardo,我试过了,但显示的行数非常有限,其余代码合并得很糟糕。
-
复制粘贴,选中后按Ctrl+K
-
太棒了,非常感谢,我在 YouTube 上播放这个,但需要更长的时间
标签: vba powerpoint