I have a presentation full of links to one excel file where all the data is gathered and made presentable from other excel files.
This is a monthly excercise and therefore I have a new directory every month. When copying the entire directory Excel keeps the links to the other files, which are also in the same directory.
However, Powerpoint (in this same directory) keeps the links to the directory it originated from.
Microsoft aknowledges this as a known problem and advises the below macro in Powerpoint, which unfortunately does not work (or I'm doing something wrong).
Can somebody please help.
Sub RelPict()
Dim oSlide As Slide
Dim oShape As Shape
Dim lPos As Long
Dim strLink As String
'
' Loop through the presentation checking each shape
' on each slide to see if it is a linked picture.
'
For Each oSlide In ActivePresentation.Slides
For Each oShape In oSlide.Shapes
If oShape.Type = msoLinkedPicture Then
With oShape.LinkFormat
'
' Search from the right hand portion of the source
' file name and find the first backslash "\" character.
'
lPos = InStrRev(.SourceFullName, "\")
'
' Check to see if the link has already been modified.
'
If lPos <> Null Then
'
' Determine how long the file name is, by subtracting
' the position the "\" character was found at from
' the total length of the source file name.
'
lPos = Len(.SourceFullName) - lPos
'
' Extract the file name from the source file name, then
' assign the file name to the source file name, turning
' it into a relative path.
'
strLink = Right(.SourceFullName, lPos)
.SourceFullName = strLink
End If
End With
End If
Next oShape
Next oSlide
End Sub
This is a monthly excercise and therefore I have a new directory every month. When copying the entire directory Excel keeps the links to the other files, which are also in the same directory.
However, Powerpoint (in this same directory) keeps the links to the directory it originated from.
Microsoft aknowledges this as a known problem and advises the below macro in Powerpoint, which unfortunately does not work (or I'm doing something wrong).
Can somebody please help.
Sub RelPict()
Dim oSlide As Slide
Dim oShape As Shape
Dim lPos As Long
Dim strLink As String
'
' Loop through the presentation checking each shape
' on each slide to see if it is a linked picture.
'
For Each oSlide In ActivePresentation.Slides
For Each oShape In oSlide.Shapes
If oShape.Type = msoLinkedPicture Then
With oShape.LinkFormat
'
' Search from the right hand portion of the source
' file name and find the first backslash "\" character.
'
lPos = InStrRev(.SourceFullName, "\")
'
' Check to see if the link has already been modified.
'
If lPos <> Null Then
'
' Determine how long the file name is, by subtracting
' the position the "\" character was found at from
' the total length of the source file name.
'
lPos = Len(.SourceFullName) - lPos
'
' Extract the file name from the source file name, then
' assign the file name to the source file name, turning
' it into a relative path.
'
strLink = Right(.SourceFullName, lPos)
.SourceFullName = strLink
End If
End With
End If
Next oShape
Next oSlide
End Sub