如何使用LotusScript将Web URL添加到文档中

时间:2022-10-31 22:14:34

I have an agent that takes a copy of a template document and puts in values from a text file.

我有一个代理,它获取模板文档的副本并从文本文件中输入值。

I am running into a problem when adding a hyperlink to a field programmatically, If I just add the text (e.g. http://www.google.com) there is no hyperlink just plain text. If I add the text manually, by editing the document just adding the address works fine and is clickable.

我在以编程方式向字段添加超链接时遇到问题,如果我只是添加文本(例如http://www.google.com),则没有超链接只是纯文本。如果我手动添加文本,通过编辑文档只需添加地址工作正常,可点击。

I have tried creating a rich text object then adding that to the field but that doesn't work either :(

我尝试创建一个富文本对象,然后将其添加到字段,但这也不起作用:(

Set rtItem = New NotesRichTextItem( doc, "link" )
Call rtitem.AddNewLine( 1 )
Call rtItem.AppendText ("http://www.google.com")
doc.AppendItemValue "Details", rtItem

To be clear, I'm looking for a way to append a clickable hyperlink to a field using lotusscript. Any help would be greatly appreciated.

为了清楚起见,我正在寻找一种方法,使用lotusscript将可点击的超链接附加到字段。任何帮助将不胜感激。

EDIT: Upon further inspection if I generate a document with a link in the text field and save it (programmatically using doc.save) it saves as plain text, as soon as I then go into this document and do a manual save the plain text turns into a link just fine. Could something be wrong with how I am saving?

编辑:进一步检查,如果我生成一个文本字段中带有链接的文档并保存(使用doc.save编程),它将保存为纯文本,然后我进入此文档并执行手动保存纯文本变成一个链接就好了。我如何储蓄可能有问题吗?

If  (Not doc.save(True,False,True)) Then
    Msgbox("Document could not save")
End If

1 个解决方案

#1


5  

It does work the way you tried in your code with just "AppendText". But, the link works only if the document is in read mode and client property "Make Internet URL ... into Hotspots" is set.

它只使用“AppendText”以您在代码中尝试的方式工作。但是,仅当文档处于读取模式且客户端属性“使Internet URL ...进入热点”时,链接才起作用。

如何使用LotusScript将Web URL添加到文档中

UPDATE:

更新:

AppendItemValue doesn't work for RichTextItems.

AppendItemValue不适用于RichTextItems。

Append the link direct to your field "Details" or if it doesn't exist then create it. Your code should look like this:

将链接直接附加到您的字段“详细信息”,或者如果它不存在则创建它。您的代码应如下所示:

Dim rtItem As NotesRichTextItem
If doc.Hasitem("Details") Then 
    Set rtitem = doc.Getfirstitem("Details")
Else 
    Set rtitem = doc.Createrichtextitem("Details")
End if
Call rtitem.AddNewLine( 1 )
Call rtItem.AppendText ("http://www.google.com")

#1


5  

It does work the way you tried in your code with just "AppendText". But, the link works only if the document is in read mode and client property "Make Internet URL ... into Hotspots" is set.

它只使用“AppendText”以您在代码中尝试的方式工作。但是,仅当文档处于读取模式且客户端属性“使Internet URL ...进入热点”时,链接才起作用。

如何使用LotusScript将Web URL添加到文档中

UPDATE:

更新:

AppendItemValue doesn't work for RichTextItems.

AppendItemValue不适用于RichTextItems。

Append the link direct to your field "Details" or if it doesn't exist then create it. Your code should look like this:

将链接直接附加到您的字段“详细信息”,或者如果它不存在则创建它。您的代码应如下所示:

Dim rtItem As NotesRichTextItem
If doc.Hasitem("Details") Then 
    Set rtitem = doc.Getfirstitem("Details")
Else 
    Set rtitem = doc.Createrichtextitem("Details")
End if
Call rtitem.AddNewLine( 1 )
Call rtItem.AppendText ("http://www.google.com")