Linkformat problem

G

Guest

The code given below work properly in powerpoint 2003,But it shows an
error message in powerpoint 2007.

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
' filename 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 filename 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 filename from the source file name, then
' assign the filename 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

I need help of some one,Please help me.
 
G

Guest

Hi

I don't get an error message but it doesn't work!

Try if lPos<>0 then instead on <> Null see if that works.
 
S

Shyam Pillai

I don't get an error. Why are you checking a long value against Null.
Change:
lPos <> Null to lPos<>0


--
Regards,
Shyam Pillai

Animation Carbon: Copy/Paste/Share animation libraries.
www.animationcarbon.com
 
G

Guest

Sorry John Wilson,
The code I have send have some mistake,the real code is as given below,

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 = 16 Then
With oShape.LinkFormat
'
' Search from the right hand portion of the source
' filename and find the first backslash "\" character.
'
lPos = InStrRev(.SourceFullName, "\")
'
' Check to see if the link has already been modified.
'
If lPos <> 0 Then
'
' Determine how long the filename 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 filename from the source file name, then
' assign the filename 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 code properly works in 2003,but shows an error message in
powerpoint 2007.
thanks a lot for your replay,
With regards MUnna
 
G

Guest

Sorry sir,My real code is given below,It properly works in powerpoint
2003,but shows an error message in 2007,Why so sir,I kindy need your help to
solve my problem



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 = 16 Then
With oShape.LinkFormat
'
' Search from the right hand portion of the source
' filename and find the first backslash "\" character.
'
lPos = InStrRev(.SourceFullName, "\")
'
' Check to see if the link has already been modified.
'
If lPos <> 0 Then
'
' Determine how long the filename 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 filename from the source file name, then
' assign the filename 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


Regards
Munna
 
G

Guest

Why did you change msoLinkedPicture to type 16? (type 16 isn't a linked
picture) Maybe you need to explain what you want to achieve.

Apart from that it works OK in 2007 here
 
G

Guest

Error Message on runnig the code in 2007 is as follows.It works
properly in 2003 witout any error message.

Run-time error '-2147467259 (80004005)':
LinkFormat(unknown member) : Failed.

With thanks,
Regards,
Munna
 
G

Guest

Sir, the shape is type msoMedia.I want to set a diffrent path address for
inserted shape.


With thanks,
Regards,
Munna
 

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