简体   繁体   中英

Variables in MS power point

Hi I am creating a powerpoint 2013 presentation in which we will be using some hyperlinks on many slides. The hyperlinks point to an external site. This server may change later and then I would need to change all these hyperlinks individually, which is quite a pain.

Is there a way by which I could define a variable in power point( maybe in the VBA section ) and then use this variable , which could be base website address, to construct the hyperlinks in the slides. This way if the website changes, then I only need to change the value of this variable. Is this possible to do and if yes, how ?

Thanks for your help !

There's no way to save the desired link address as, say, a field code as you might be able to do in Word, but if you don't mind running a bit of code to do the fixup, this will let you replace any specific chunk of text with any other text. You supply the bits. In the example below, I'm replacing pptools with pptfaq, to turn all hyperlinks to http://www.pptools.com into http://www.pptfaq.com

Edit the first two lines as needed:

Const sOldHyperlink As String = "pptools"
Const sNewHyperlink As String = "pptfaq"

Sub ChangeHyperlinks()

    Dim oSl As Slide
    Dim oHl As Hyperlink

    For Each oSl In ActivePresentation.Slides
        For Each oHl In oSl.Hyperlinks
            oHl.Address = Replace(oHl.Address, sOldHyperlink, sNewHyperlink)
        Next
    Next

End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM