我有一个大问题=) 我将电子邮件的漏洞内容复制到clipbard,并需要将此内容粘贴到richtextfield中。
现在我的问题是,将这些内容从剪贴板粘贴到一个部分中。
所以我必须在用户所在的当前Richtextfield中创建一个部分,并将剪贴板中的内容粘贴到此部分。
我尝试过不同的方法,但没有任何效果。 也许有RTNavigators或范围的解决方案,但我不知道。
有人为我提供了可能的解决方案吗?
提前致谢
parent {
int id
}
children {
int id
int parent_id
int status
}
第二次尝试
Dim s As New NotesSession
Dim db As NotesDatabase
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim currField As String
Dim rtitem As NotesRichTextItem
Dim style As NotesRichTextStyle
Dim color As NotesColorObject
Set uidoc = ws.Currentdocument
Set db = s.Currentdatabase
Dim DummyDoc As NotesDocument
Dim DummyRT As NotesRichTextItem
currField = uidoc.Currentfield
'Create DummyDoc
Set DummyDoc = db.CreateDocument
Call DummyDoc.Createrichtextitem("dummy")
Set DummyRT = DummyDoc.Createrichtextitem("DummyRT")
Call DummyDoc.Save(True,True)
'Open DummyDoc in workspace
Dim dummyUIDoc As NotesUIDocument
Set dummyUIDoc = ws.Editdocument(True, DummyDoc,True)
'Paste copied content
Call dummyUIDoc.Gotofield("dummy")
Call dummyUIDoc.Paste()
Call dummyUIDoc.Refresh(True,False,True)
Call dummyUIDoc.Save()
Call dummyUIDoc.Close(True)
'Create Section
Dim secUIDoc As NotesUIDocument
Set style = s.CreateRichTextStyle
Set color = s.CreateColorObject
Call DummyRT.BeginSection("", style, color, True)
Call DummyRT.EndSection
Call DummyDoc.Save(True, False, False)
Set secUIDoc = ws.EditDocument(True, DummyDoc)
Call DummyDoc.Remove(True)
Call secUIDoc.Gotofield("DummyRT")
Call secUIDoc.Selectall()
Call secUIDoc.Copy()
Call secUIDoc.Close(true)
'Paste generated content
Call uidoc.Gotofield(currField)
Call uidoc.Paste()
Dim range As NotesRichTextRange
Dim count As Integer
Dim nav As NotesRichTextNavigator
Set rtitem = uidoc.Document.Getfirstitem(currField)
Set range = rtitem.CreateRange
Set nav = rtitem.CreateNavigator
Call nav.FindFirstString("#PH#")
Call range.SetBegin(nav)
Call range.SetEnd(nav)
Call range.Remove
Call uidoc.Paste()
答案 0 :(得分:0)
BreakingPar有访问Windows剪贴板的代码:http://www.breakingpar.com/bkp/home.nsf/0/87256B280015193F87256CFA00581AB2
您似乎对使用RTNavigators有一些疑问,我认为这是要走的路。希望它对你有所帮助,我包括一个按钮,我使用RTNavigators添加一个表格。我没有使用部分,但我可能会有帮助。
干杯, 布赖恩
Sub Click(Source As Button)
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim firstDoc As NotesDocument
Dim tableDoc As New NotesDocument(db)
Set uidoc = ws.CurrentDocument
Dim univID As String
Set firstDoc = uidoc.Document
univID = firstDoc.UniversalID
Call uidoc.Close
Msgbox univID
Dim tableItem As NotesRichTextItem
Call tableDoc.ReplaceItemValue("Form","Table Holder")
Dim body As New NotesRichTextItem(tableDoc,"BuiltTable")
rowCount% = 4
columnCount% = 4
'Order the table
Call body.AppendTable(rowCount%,columnCount%)
Dim rtnav As NotesRichTextNavigator
Set rtnav = body.CreateNavigator
Call rtnav.FindFirstElement(RTELEM_TYPE_TABLECELL)
For iRow% = 1 To rowCount% Step 1
For iColumn% = 1 To columnCount% Step 1
Call body.BeginInsert(rtnav)
Call body.AppendText("Row " & iRow% & ", Column " & iColumn%)
Call body.EndInsert
Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)
Next
Next
Call tableDoc.Save(True, False)
Set tableItem = tableDoc.GetFirstItem("BuiltTable")
'Call tableItem.CopyItemToDocument(doc,"TableTarget")
Call tableItem.CopyItemToDocument(firstDoc, "TableTarget")
Call firstDoc.Save(True,False)
Call ws.ViewRefresh
Call ws.EditDocument(True,firstDoc,False)
End Sub
答案 1 :(得分:0)
或者,如果您知道原始字段的名称,则可以使用以下代码将RT字段从一个文档复制到另一个文档。 “NewLink”是我的起源字段的名称。
干杯, 布赖恩
Dim thisDoc As NotesDocument
Dim thisRT As Variant
Dim newRT As Variant
Dim newDoc As NotesDocument
Set uiws = New NotesUIWorkspace
Set sess = New NotesSession
Set db = sess.CurrentDatabase
Set thisuidoc = uiws.CurrentDocument
Set thisDoc = thisuidoc.Document
Set thisRT = thisDoc.GetFirstItem("NewLink")
Set newDoc = db.CreateDocument
newDoc.Form = "RT"
Call newDoc.Save(True,False)
Set newRT = New NotesRichTextItem(newdoc,"newRTfield")
Call thisuidoc.Close
Call newRT.AppendRTItem(thisRT)
Call newdoc.Save(True,False)
Set newuidoc = uiws.EditDocument(True, newDoc)