Link to home
Start Free TrialLog in
Avatar of Faraj1969
Faraj1969Flag for Liberia

asked on

Lotusscript - Creating Hotspots

I have a RichTextItem on the document to have all links to external files like (Word, Excel, Pdf, etc..). All those documents are stored on a mapped network drive. When user creates a new document, and tries to create a link, I present them with a dialogbox to get the text that should appear and the actual link of the file. How can I create a hotspot link of the file and append it to the RichTextItem field so it can be clickable ?
Avatar of Sjef Bosman
Sjef Bosman
Flag of France image

Avatar of Faraj1969

ASKER

Yes, but almost doesn't count... ;)

What I need exactly, first part, user will click on a button to open directory, user will browse for the file, the file path will be returned as a string array. (this part is done already).

Second part is, via Lotusscript, I need to convert the file path into a hotspot link and insert it into a Rich Text Field. (this is what I'm struggling with).
ASKER CERTIFIED SOLUTION
Avatar of Sjef Bosman
Sjef Bosman
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Here's the code I wrote based on your recommendation:
----------------------------------------
Sub Click(Source As Button)
   Dim sesSe As New NotesSession
   Dim uiSpace As New NotesUIWorkspace
   Dim uidDoc As NotesUIDocument
   Dim srcDoc As NotesDocument
   Dim rtfStyle As NotesRichTextStyle
   Dim rtfLinks As NotesRichTextItem
      
   Set uidDoc = uiSpace.CurrentDocument
   Set srcDoc = uidDoc.Document
   Set rtfStyle = sesSe.CreateRichTextStyle
   Set rtfLinks = srcDoc.GetFirstItem("Untitled")

   strLink$ = "<a id='myLink' href='file://" + uidDoc.FieldGetText("Untitled3") + "'>" + _ uidDoc.FieldGetText("Untitled2") + "</a></body></html>"

   rtfStyle.PassThruHTML = True
   Call rtfLinks.AppendStyle(rtfStyle)
   Call rtfLinks.AppendText(strLink$)
   Call srcDoc.Save(True, False)
   Call uidDoc.Reload
End Sub
----------------------------------------

I click the button after I save the document, and the debugger runs nicely without problems, but nothing is happening. the Untitled field is Rich Text, and is set to Store contents as HTML and MIME.

Any idea's ?
For the sake of testing I changed the code to this:
-------------------------------------------------
Sub Click(Source As Button)
   Dim sesSe As New NotesSession
   Dim uiSpace As New NotesUIWorkspace
   Dim uidDoc As NotesUIDocument
   Dim srcDoc As NotesDocument
   Dim rtfStyle As NotesRichTextStyle
   Dim rtfLinks As NotesRichTextItem
      
   Set uidDoc = uiSpace.CurrentDocument
   Set srcDoc = uidDoc.Document
   Set rtfStyle = sesSe.CreateRichTextStyle
   Set rtfLinks = srcDoc.GetFirstItem("Untitled")
      
   strLink$ = "<a id='myLink' href='file://c:\foo.html'>Just a file to open</a>"

   rtfStyle.Bold = True
   rtfStyle.NotesColor = COLOR_GREEN
   rtfStyle.PassThruHTML = True
   rtfStyle.Underline = True

   Call rtfLinks.AppendStyle(rtfStyle)
   Call rtfLinks.AppendText(strLink$)
   Call srcDoc.Save(True, False)
   Call uidDoc.Reload
End Sub
-------------------------------------------------
What am I doing wrong ?
Cheers
I remember the days when I used to get an answer in less than 5 minutes, and I kept my subscription for a long time without using it, just wanted to really support the site. Anyway, this question also is not answered, but I'll accept sjef_bosman answer for the points, and sorry to say that I'll just cancel my membership here.

Wish you all the best.
I hope you know that the Experts at EE are just volunteers. There's nothing for us here, no dollars, except maybe some glory plus the satisfaction when we can successfully help someone out.

Anyway, I was mistaken about the passthru-html stuff. Please have a look at the NotesRichTextDocLink class. There's a document in the Help database called "Working with doclinks in LotusScript classes". It seems necessary to create a doclink first, using AppendDocLink, before you can turn it into a hotspot.

Sorry that I had to go shopping in order to have some supper...