changing links in multiple ppt files using search and replace

C

Compwiz

I have a client with 100's of files all using links to even more
files. I need to move all the files and associated files from the
current server to a new server. Opening each file to update the links
is too time consuming. Is there a tool or script that I can point at a
folder and have it scan through each powerpoint file and replace
x:\path\to\file with \\server\share\path\to\file.

I have found commercial software to do this for Excel and Word,
but no luck for Powerpoint. Any ideas?

Thanks,

William
 
C

Compwiz

That looks promising. I will try it when I can. Unfortunately, this is
just one of multiple issues I am working on ;)

William
 
C

Compwiz

Thanks for the help. I tried to work this out this morning. But I am
still having issues. Can you see if I made a mistake?

This is my first try at VBA. It looks like I got a macro that is
opening files in a folder but after it runs, I go to check the paths on
the links and they haven't changed.

I tried running just the Change OLE Links macro on a test file and I
get the popup saying Done, but when I look it has no changes made. I am
using PPT 2002 SP3 with Medium security on a Server 2003 SP1 system.

For the OLE only test, I cut and paste straight from the web page and
only changed the paths.

Here is what I cobbled together for the folder / ole changes search and
replace -

Sub ForEachPresentation()
' Run a macro of your choosing on each presentation in a folder

Dim rayFileList() As String
Dim FolderPath As String
Dim FileSpec
Dim strTemp As String
Dim x As Long

' EDIT THESE to suit your situation
FolderPath = "C:\public\" ' Note: MUST end in \
FileSpec = "*.ppt"
' END OF EDITS

' Fill the array with files that meet the spec above
ReDim rayFileList(1 To 1) As String
strTemp = Dir$(FolderPath & FileSpec)
While strTemp <> ""
rayFileList(UBound(rayFileList)) = FolderPath & strTemp
ReDim Preserve rayFileList(1 To UBound(rayFileList) + 1) As
String
strTemp = Dir
Wend

' array has one blank element at end - don't process it
' don't do anything if there's less than one element
If UBound(rayFileList) > 1 Then
For x = 1 To UBound(rayFileList) - 1
Call MyMacro(rayFileList(x))
Next x
End If

End Sub

Sub MyMacro(strMyFile As String)
' this gets called once for each file that meets the spec you enter in
ForEachPresentation
' strMyFile is set to the file name each time

' Probably at a minimum, you'd want to:
Dim oPresentation As Presentation
Set oPresentation = Presentations.Open(strMyFile)

With oPresentation


' Note: this will only work in PPT 2000 and later

Dim oSld As Slide
Dim oSh As Shape
Dim sOldPath As String
Dim sNewPath As String

' EDIT THIS TO REFLECT THE PATHS YOU WANT TO CHANGE
' Include just the portion of the path you want to change
' For example, to change links to reflect that files have moved
from
' \\boss\p-drive\temp\*.* to
' \\boss\Q-drive\temp\*.*
sOldPath = "c:\public\"
sNewPath = "\\fs1\data\public\"

For Each oSld In oPresentation.Slides
For Each oSh In oSld.Shapes
' Change only linked OLE objects
If oSh.Type = msoLinkedOLEObject Then
On Error Resume Next
oSh.LinkFormat.SourceFullName =
Replace(oSh.LinkFormat.SourceFullName, sOldPath, sNewPath)
End If
Next ' shape
Next ' slide


End With

oPresentation.Save
oPresentation.Close

End Sub
 
C

Compwiz

Yes, the path is correct. I had set up a test document and data links
to make sure everything was in the right place before I started.

I also just tried using the mapped drive path P:\public instead of the
UNC \\fs1\data\public and it did not make a difference either way.

BTW, I just heard from Datamystic.com that they have updated their
commercial tool to do exactly what we are talking about. I tested the
demo on my doc's and it worked. So, I have an alternate option but
would like getting this to work better. when possible, I like
tinkering with stuff to increase my knowledge <g>

Thanks for taking the time to answer my questions. I appreciate it.

William
 
C

Compwiz

I just had an issue with the differences between the office install on
a terminal server vs a stand alone with outlook forms. Maybe there is a
component missing from PPT too. I will try the same tests on a stand
alone next chance I get to see if it is the Power Point install itself.

William
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top