【发布时间】:2019-09-07 13:01:21
【问题描述】:
我想在 PowerPoint 中获取带有超链接的形状。
我将使用 pdf.js 将 powerpoint 显示为 pdf,并且需要在渲染的 pdf 上使用正确大小的形状覆盖 html 以附加超链接。
但是如果我尝试使用LinkFormat.SourceFullName 方法,它会抛出错误
无效请求
我已经用绝对链接的图像和形状对其进行了测试。不知何故,我的链接形状的类型是 autoShapeTypes。
我使用 Office 356。我主要对演示文稿中的幻灯片链接感兴趣。我可以通过 pptSlide.Hyperlinks(i) 及其 SubAddress 访问它们,但是如何获得指向该链接的引用形状?
任何想法为什么形状不会显示为链接对象以及我如何能够从形状中获取链接?
Dim pptPresentation As Presentation
Dim pptSlide As Slide
Dim pptShape As Shape
Dim i As Integer
dim linkstring as String
Dim hl As Hyperlink
'Set the variable to the PowerPoint Presentation
Set pptPresentation = ActivePresentation
'Loop through each slide in the presentation
For Each pptSlide In pptPresentation.Slides
'Loop through each shape in each slide
For Each pptShape In pptSlide.Shapes
'Find out if the shape is a linked object or a linked picture
If pptShape.Type = msoLinkedPicture Or pptShape.Type _
= msoLinkedOLEObject Or pptShape.Type = msoLinked3DModel Then
'won't make it into the loop, ad Or 1 for AutoShapeTyps
linkstring = pptShape.LinkFormat.SourceFullName
oFile.WriteLine "link:" & linkstring & vbNewLine & _
"height:" & pptShape.Height & vbNewLine & _
"width:" & pptShape.Width & vbNewLine & _
"pos-left" & pptShape.Left & vbNewLine & _
"pos-top " & pptShape.Top & vbNewLine & _
vbNewLine
End If
Next
Next
'test to see if vba finds any links at all
For Each hl In ActivePresentation.Slides(1).Hyperlinks
linkstring = hl.Address
linkstring = hl.SubAddress
linkstring = hl.Application
linkstring = hl.Type
Next
【问题讨论】:
-
您混合了两种不同的东西:a) 到其他幻灯片或 URL 的超链接 (=ActionSetting) 和 b) 未嵌入但链接的图像(=链接对象)。正如您提到的幻灯片链接,我为此写了一个很长的答案。
标签: vba hyperlink powerpoint