changing links in multiple ppt files using search and replace

  • Thread starter Thread starter Compwiz
  • Start date Start date
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
 
Compwiz said:
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?

Much as I'd love to sell you a copy of FixLinks to do this, it doesn't do batch
conversion. Yet.

On the other hand, you could combine bits of several pages from the PPT FAQ:

Batch: Do something to every file in a folder
http://www.rdpslides.com/pptfaq/FAQ00536.htm

Search & Replace to change OLE link paths
http://www.rdpslides.com/pptfaq/FAQ00759.htm

and with a few mods, have something that should do the job for you.
 
That looks promising. I will try it when I can. Unfortunately, this is
just one of multiple issues I am working on ;)

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

No problem. Clue us in on the other issues (the PPT ones that is), we'll run in
 
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
 
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.

First thing to check: are the needed files in the folder you're resetting the link to
point to? That is, if you have an existing link to

c:\oldfolder\something.xls

and you're resetting it to

c:\NEWfolder\something.xls

you have to make sure that something.xls is actually in c:\NEWfolder\ first.

Otherwise, PowerPoint will let you set the link to anything you like, nod happily, go
"Yes boss, anything you say, boss" ... and ignore you.
 
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
 
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.

Not sure what the problem would be then ... several people have used the same code to do
this with good results.

Try commenting out "On Error Resume Next" here:

On Error Resume Next
oSh.LinkFormat.SourceFullName =
Replace(oSh.LinkFormat.SourceFullName, sOldPath, sNewPath)

See if it errors at that point.
 
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
 
Back
Top