vba 超链接和形状创建 [英] vba hyperlinks and shape creation
本文介绍了vba 超链接和形状创建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个可以创建形状的子程序,但是我的代码有两个问题:
I have a subroutine that will create a shape, but I have two problems with the code:
- 我必须指定将在哪个幻灯片上创建此形状.如果我想同时在多张幻灯片上创建相同的形状,这是一个问题.我如何做到这一点?我应该用什么替换 activepresentation.slides(x) ?
- 我希望形状具有指向特定幻灯片的超链接.我的代码有什么问题来实现这一目标?当我尝试为我创建的形状分配一个操作时,它给了我一个错误.
Sub createshape()
Dim oshp As Shape
Dim osld As Slide
'old code
Set osld = ActivePresentation.Slides(1)
Set oshp = osld.Shapes.AddShape(msoShapeRectangle, 485, 15, 104, 60)
oshp.ActionSettings (ppMouseClick)
.Action = ppActionHyperlink
.Hyperlink.Address = SlideNumber
.Hyperlink.SubAddress = 1 'this should take the hyperlink to slide 1 i hope.
End Sub
我想自动化这个功能,因为我会多次为许多幻灯片做同样的事情.
I want to automate this function because I will be doing this same thing for many many slides multiple times.
推荐答案
类似这样的内容将作用于当前幻灯片.我测试了幻灯片 2 的超链接以确保代码有效(并且没有使用 1 作为默认值)
Something like this will act on the current slide. I tested for a slide 2 hyperlink to esnure that the code worked (and didn't use 1 as default)
Sub CreateShape()
Dim oShp As Shape
Dim oSld As Slide
Set oSld = ActivePresentation.Slides(ActiveWindow.Selection.SlideRange.SlideIndex)
Set oShp = oSld.Shapes.AddShape(msoShapeRectangle, 485, 15, 104, 60)
With oShp.ActionSettings(ppMouseClick)
.Action = ppActionHyperlink
'.Hyperlink.Address = SlideNumber
.Hyperlink.SubAddress = 2
End With
End Sub
这篇关于vba 超链接和形状创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文