Created
May 2, 2017 13:52
-
-
Save kuzeko/724ea046be89c6d281511f6fe77c09c0 to your computer and use it in GitHub Desktop.
VBA Script for Macro: Editing the Embedded Chart Link in a Powerpoint Presentation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub EditLink() | |
' Edit links of some types | |
' Little error checking. It works or not. No harm if not. | |
Dim sLinkSource As String | |
Dim sOriginalLinkSource As String | |
If ActiveWindow.Selection.ShapeRange.Count <> 1 Then | |
MsgBox ("Please select one and only one shape, then try again.") | |
Exit Sub | |
End If | |
With ActiveWindow.Selection.ShapeRange(1) | |
'MsgBox .LinkFormat.SourceFullName | |
sOriginalLinkSource = .LinkFormat.SourceFullName | |
sLinkSource = InputBox("Edit the link", "Link Editor", sOriginalLinkSource) | |
If sLinkSource = sOriginalLinkSource Then | |
' nothing changed; our work on this planet is done | |
Exit Sub | |
End If | |
If sLinkSource = "" Then | |
' The user canceled; quit: | |
Exit Sub | |
End If | |
' Get the filename portion of the link in case it's a link to a range | |
Debug.Print Mid$(sLinkSource, 1, InStr(sLinkSource, ".") + 3) | |
' Is it a valid filename? Is the file where it belongs? | |
' Test against the filename portion of the link in case the link includes | |
' range information | |
' Check for FileName doesn't work on Mac | |
'If Dir$(Mid$(sLinkSource, 1, InStr(sLinkSource, ".") + 3)) <> "" Then | |
.LinkFormat.SourceFullName = sLinkSource | |
.LinkFormat.Update | |
'Else | |
' MsgBox "Can't find " & sLinkSource | |
'End If | |
End With | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment