We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Cannot set Link Properties

Im trying to run the following code:

Dim tf As TextFrame = tbl.GetCell(5, n_rows).TextFrame
attacharray = Split(attachment_path_string, Chr(13))
list = New ArrayList(attacharray)
pgraph = tbl.GetCell(5, n_rows).TextFrame.Paragraphs
pgraph(0).Portions(0).Text = ""
pgraph(0).Portions(0).FontHeight = 8
Dim lnk As Link
If list.Count > 0 Then
pgraph(0).Portions(0).Text = "1" 'list(0)
For i = 1 To list.Count - 1
lnk = tf.AddLink()
pgraph.Add(New Paragraph(pgraph(0)))
pgraph(i).Text = ""
pgraph(i).Portions(0).Text = ""
pgraph(i).Portions(0).FontHeight = 8
pgraph(i).Portions(0).Text = i 'list(i)
Dim begin As Integer = tf.Text.IndexOf(i)
lnk.Begin = begin
lnk.End = lnk.Begin + 1
lnk.SetExternalHyperlink(list(i))
Next
End If

for the variable begin, i get a value pointing to the index im looking for, but for some reason, no matter what i do, lnk.begin and lnk.end always stay as 0. I set them equal to integer variables with non zero values in them, but it never takes. What am I doing wrong?

Thanks

Dear Ross,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I have corrected your code. Please see the code below and its output file attached in this post.

You had actually this line wrong

lnk = tf.AddLink()

so I corrected it with this line

lnk = tf.Links.AddLink()

VB.NET CODE

Dim attacharray() As String

Dim attachment_path_string = "http://www.aspose.com" & Chr(13) & "http://www.google.com" & Chr(13) & "http://www.yahoo.com"

Dim List As ArrayList

Dim pgraph As Paragraphs

Dim para As Paragraph

Dim n_rows As Integer = 0

Dim i As Integer

Dim pres As New Presentation

Dim sld As Slide = pres.GetSlideByPosition(1)

Dim tbl As Table = sld.Shapes.AddTable(100, 100, 5000, 2000, 6, 3)

Dim tf As TextFrame = tbl.GetCell(5, n_rows).TextFrame

attacharray = Split(attachment_path_string, Chr(13))

List = New ArrayList(attacharray)

pgraph = tbl.GetCell(5, n_rows).TextFrame.Paragraphs

pgraph(0).Portions(0).Text = ""

pgraph(0).Portions(0).FontHeight = 8

tf.Links.Clear()

Dim lnk As Link

If List.Count > 0 Then

pgraph(0).Portions(0).Text = "1" 'list(0)

For i = 1 To List.Count

lnk = tf.Links.AddLink()

Dim begin As Integer = tf.Text.IndexOf(i)

lnk.Begin = begin

lnk.End = lnk.Begin + 1

lnk.SetExternalHyperlink(List(i - 1))

pgraph.Add(New Paragraph(pgraph(0)))

pgraph(i).Text = ""

pgraph(i).Portions(0).Text = ""

pgraph(i).Portions(0).FontHeight = 8

pgraph(i).Portions(0).Text = i + 1 'list(i)

Next

End If

pgraph.RemoveAt(pgraph.Count - 1)

pres.Write("c:\out.ppt")

awesome, thanks so much! thats working perfectly!

just one more question. the text that is now a hyperlink is a very bright yellow color thats difficult to read. any way of changing the color of linked text?

Actually, you will have to edit your color scheme.

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

In PowerPoint, you can do so by Format -- > Slide Design then from the Slide Design Pane, select Color Schemes -- > Edit Color Schemes and double click Accent & Hyperlink.

Or you can change the scheme color using this code

'Change Hyperlink color to RED

Dim HYPERLINK_SCHEME_COLOR_IDX As Integer = 6

sld.SetSchemeColor(HYPERLINK_SCHEME_COLOR_IDX, Drawing.Color.Red)