PDA

View Full Version : Save an unlinked version?



trevor26
09-26-2007, 05:35 PM
Hi,

I have a powerpoint presentation that uses linked excel files.

I want to create a macro that every month will save an unlinked copy of itself to the archive folder.

Is that possible?

I did find a thread on this forum about just preventing the update links prompt (thread 7543) which could work for the archive version, but can a macro insert a macro then save the presentation as another filename?
Obviously I dont want my original file to stop asking to update the links.

HYCH

John Wilson
09-27-2007, 07:57 AM
You should be able to use ActivePresentation.SaveCopyAs (FileName) to make a copy and then open it with vbaPresentations.Open (FileName)

and break the links before a resave by searching out the linked shapes set to = oshp and
oshp.LinkFormat.BreakLink

trevor26
09-27-2007, 05:48 PM
Brilliant thank you!

I am new to this, how exactly would I find all the links?

John Wilson
09-27-2007, 11:37 PM
Something like this (not tested)


Sub findme_andbreak()
Dim osld As Slide
Dim oshp As Shape
Dim opres As Presentation
Set opres = ActivePresentation
opres.SaveCopyAs (Environ("USERPROFILE") & "\Desktop\backup.ppt")
opres.Close
Set opres = Presentations.Open(Environ("USERPROFILE") & "\Desktop\backup.ppt")
For Each osld In opres.Slides
For Each oshp In osld.Shapes
If oshp.Type = msoLinkedOLEObject Then
oshp.LinkFormat.BreakLink
End If
Next oshp
Next osld
End Sub

Then save and delete the temp copy on the desktop

trevor26
09-27-2007, 11:52 PM
Thanks.

It seems to have trouble with the line:


oshp.LinkFormat.BreakLink

(it highlights .Breaklink )

It says
Method or Data Member not found

John Wilson
09-28-2007, 12:36 AM
OK I tested it this time.

Apart from the fact you can't close the opres with the code in it! (just take that line out) it works perfectly here. What version of PowerPoint do you have. I'm on 2007 but I'm pretty sure .Breaklink was added in XP

John Wilson
09-28-2007, 12:41 AM
OK Sorry it seems this is only available in 2007

John Wilson
09-28-2007, 12:56 AM
See if this does it for you (most of the code came from fellow MVP Shyam Pillai)
Sub breaklinks()
Dim oSld As Slide
Dim oShp As Shape
Dim opres As Presentation
Set opres = ActivePresentation
Dim oCmdButton As CommandBarButton
Set opres = ActivePresentation
opres.SaveCopyAs (Environ("USERPROFILE") & "\Desktop\tempbackup.ppt")
Set opres = Presentations.Open(Environ("USERPROFILE") & "\Desktop\tempbackup.ppt")
Set oCmdButton = CommandBars("Standard").Controls.Add(Id:=2956)
ActiveWindow.ViewType = ppViewSlide
For Each oSld In opres.Slides
For Each oShp In oSld.Shapes
If oShp.Type = msoLinkedOLEObject Then
ActiveWindow.View.GotoSlide oSld.SlideIndex
oShp.Select
Application.CommandBars.FindControl(Id:=2956).Execute
DoEvents
End If
Next oShp
Next oSld
oCmdButton.Delete
End Sub

walkthrough
07-15-2008, 11:00 AM
Hello,

I am trying to write a code that automaticly break the link in PowerPoint.

Here is a code I found online I modified the oBegin, oEnd in this code

But it didn't work.

Can you help!

Sub BreakLinks()

Dim oShp As Shape
Dim oBegin As Integer
Dim oEnd As Integer
Dim oSldCount As Integer
oSldCount = ActivePresentation.Slides.Count

'This prompt the user to input figure size and location
oBegin = InputBox("What is beginning page", "Beginning page", 1)
oEnd = InputBox("What is ending page", "Ending page", oSldCount)

For I = oBegin To oEnd
For Each oShp In ActivePresentation.Slides(I).Shapes
With oShp
If .Type = msoLinkedOLEObject Then
.LinkFormat.BreakLink
End If
End With
Next oShp
Next I
End Sub

asingh
10-07-2008, 01:43 AM
See if this does it for you (most of the code came from fellow MVP Shyam Pillai)
Sub breaklinks()
Dim oSld As Slide
Dim oShp As Shape
Dim opres As Presentation
Set opres = ActivePresentation
Dim oCmdButton As CommandBarButton
Set opres = ActivePresentation
opres.SaveCopyAs (Environ("USERPROFILE") & "\Desktop\tempbackup.ppt")
Set opres = Presentations.Open(Environ("USERPROFILE") & "\Desktop\tempbackup.ppt")
Set oCmdButton = CommandBars("Standard").Controls.Add(Id:=2956)
ActiveWindow.ViewType = ppViewSlide
For Each oSld In opres.Slides
For Each oShp In oSld.Shapes
If oShp.Type = msoLinkedOLEObject Then
ActiveWindow.View.GotoSlide oSld.SlideIndex
oShp.Select
Application.CommandBars.FindControl(Id:=2956).Execute
DoEvents
End If
Next oShp
Next oSld
oCmdButton.Delete
End Sub

Hi I was searching the net for a solution to break links from PPT (office 2003)..and found this thread.

I tried the code, but the links were not removed. Should there be some more code..? Which is missing..thanks a lot for the help.

regards,

asingh

John Wilson
10-07-2008, 04:50 AM
Hi the code is complete and works here in 2003. Are you sure your link is an LinkedOLEObject?

asingh
10-07-2008, 07:58 AM
Sorry did not mention it the first time round...yes..the OLE objects..become static images, but I can still see the "links"...in the edit>>>links interface. How to get rid of that..??