VBA 宏,用于在 PowerPoint 中插入来自 URL 的图像

VBA macro to insert image from URL in PowerPoint

我能得到一些帮助在 PPT 中编写一个 VBA 宏,它将执行以下两个任务:

  1. 插入一张新幻灯片(标题和内容格式)
  2. 将 URL 中的图像(SVG 格式)插入内容区域。 URL 具有许多呈现 "svg" 图像的查询字符串参数。

非常感谢。

请参阅下面的精简 VBA 示例,通过 ImageMagick V6 处理图像文件(V7 将 convert 命令更改为 magick).这是一个非常简单的命令示例。 ImageMagick 有数百个参数,您需要从 ImageMagick

中找到图像处理操作所需的参数
' ***********************************************************************************
' Purpose : Convert an image file from one format to another using ImageMagick
' Dependencies : Requires ImageMagic DLL package for Windows (V6) to be pre-installed
' Author  : Jamie Garroch of YOUpresent Ltd. (http://youpresent.co.uk/)
' ***********************************************************************************
Public Sub TestImageMagic()
  Dim sCmd As String
  Dim retval As Variant
  Const ImgIn = "C:\Temp\ImageIn.svg"
  Const ImgOut = "C:\Temp\ImageOut.png"
  Const QUOT = """"
  ' Construct the ImageMagick command line in the format:
  ' "C:\Program Files\ImageMagick-6.9.1-Q16\convert" "C:\Temp\ImageIn.svg" "C:\Temp\ImageOut.png"
  sCmd = QUOT & GetInstallPathIM & "\" & "convert" & QUOT & _
         " " & QUOT & ImgIn & QUOT & _
         " " & QUOT & ImgOut & QUOT
  On Error Resume Next
  ' Process the image with ImageMagic
  If Len(sCmd) <= 8192 Then retval = oShell.Run(sCmd, 0, True)
  If retval <> 0 Or Err <> 0 Then
    ' Manage errors
  End If
  On Error Goto 0
End Sub

' ***********************************************************************************
' Purpose : Function to return the installation path for ImageMagic
'           from the Windows Environment Path string.
' Author  : Jamie Garroch of YOUpresent Ltd. (http://youpresent.co.uk/)
' ***********************************************************************************
Private Function GetImageMagickPath() As String
  Dim WinPath As String ' Windows Environment Path string
  Dim IM As Integer ' Position of the start of ImageMagic string
  Dim PathStart As Integer ' Position of first left semi-colon of the ImageMagic string
  Dim PathEnd As Integer ' Position of right semi-colon of the ImageMagic string

  ' Get the Windows Environment Path string
  WinPath = Environ("PATH")
  ' Parse out the ImageMagick path by looking for ImageMagick and then searching back and forwards to the previous and next occurrence of ";"
  IM = InStr(1, WinPath, "ImageMagick")
  If IM > 0 Then
    PathStart = InStrRev(WinPath, ";", IM) + 1
    PathEnd = InStr(IM, WinPath, ";")
    GetImageMagickPath = Mid(WinPath, PathStart, PathEnd - PathStart)
  Else
    MsgBox "ImageMagick components aren't installed!"
  End If
End Function