Internal hyperlink when a picture is clicked

I want to add a internal hyperlink when a picture is clicked


tried this way and Im getting error Object reference not set to an instance of an object


pf_ecuador.Link.InternalHyperlink.Equals(2)


Dear south,

First add a link to shape (picture), using Shape.AddLink method and then use Shape.Link.SetInternalHyperLink

e.g

Shape shp = sld.Shapes[0]; //this could be a pictureframe

shp.ClearLink();

//clicking the shape will move you to slide 4
shp.AddLink().SetInternalHyperlink(source.GetSlideByPosition(4));

This code below works the first time through the loop … but the next time through the loop the DownToCountrySlide = nothing and returns object reference is not set to instance of the object. Why when i set the slide position with my variable does it equal nothing, not the correct position. You can see i set the getSlideByPosition to (a + 1 + i2). The problem im trying to solve is i need to set an internal hyperlink dynamically depending on if a database value exists and the coresponding slide is created.

For Each dr2 In ds2.Tables(0).Rows
Dim DownToCountrySlide As Slide
DownToCountrySlide = pres.GetSlideByPosition(a + 1 + i2)

If (ds2.Tables(0).Rows(i2).Item(0).ToString) = “Argentina” Then
pf_argentina.ClearLink()
pf_argentina.AddLink().SetInternalHyperlink(DownToCountrySlide)
ElseIf (ds2.Tables(0).Rows(i2).Item(0).ToString) = “Bahamas” Then
'pf_bahamas.ClearLink()
'pf_bahamas.AddLink().SetInternalHyperlink(DownToCountrySlide)


next

if a+1+i2 is greater than pres.Slides.LastSlidePosition, then it will return nothing

Please note, normal slide positions start from 1 upto Presentation.Slides.LastSlidePosition

It means, Presentation.GetSlideByPostion should be passed any integer value in the above range, all others will return nothing.