2014-09-26 23 views
0

我是一名實習生,目前正在學習LotusNotes,所以我現在還不太流利。LotusNotes 8.5 - 用按鈕向表中添加一行

我的問題是,我該如何編程一個動作按鈕來將行添加到LotusNotes 8.5中的現有表中?

我曾嘗試下面的代碼,但它並沒有爲我工作,


Sub Click(Source As Button) 
Dim uiw As New NotesUIWorkspace 
Dim uidoc As NotesUIDocument 
Set uidoc = uiw.CurrentDocument 
Dim doc As NotesDocument 
Set doc = uidoc.Document  

Dim Body As NotesRichTextItem 
Set body = doc.GetFirstItem("Body") 
If body Is Nothing Then 
Msgbox "Click on the Reset the demo action to create the table first." 
End If 

Dim rows As Integer, rownumber As Integer, numrowstoadd As Integer 
Dim strrownumber As String, strrowstoadd As String 

Dim rtnav As NotesRichTextNavigator 
Set rtnav = body.CreateNavigator 
Dim rttable As NotesRichTextTable 
Set rttable = rtnav.GetFirstElement(RTELEM_TYPE_TABLE) 
If rttable Is Nothing Then 
Msgbox "No table created - use the Reset the demo action first." 
Else 
rows=rttable.RowCount 
strrowstoadd = Inputbox("Enter the number of rows to add.") 
If Isnumeric(strrowstoadd) Then 
numrowstoAdd = Cint(strrowstoAdd) 
If numrowstoAdd <= 0 Then 
Msgbox "Enter a number greater than zero." 
Exit Sub 
End If 
Else 
Msgbox ("Enter a integer number only.") 
Exit Sub 
End If 

strrownumber = Inputbox("Enter the number corresponding to the row to start adding at, no greater than " & rows & ".") 
If Isnumeric(strrownumber) Then 
rownumber = Cint(strrownumber) 
If rownumber < 0 Or rownumber > rows Then 
Msgbox ("You entered too high a number or a number less than zero, try again.") 
Exit Sub 
End If 
Else 
Msgbox ("Enter a integer number only.") 
Exit Sub 
End If 

Call rttable.AddRow(numrowstoadd, rownumber)  
End If 

doc.save True, True 
uidoc.Close 
Call uiw.EditDocument(False,doc) 
End Sub 

任何幫助將是巨大的。謝謝!

回答

2

沒有仔細研究你的代碼,我相信你所面臨的基本問題很可能是NotesRichText類是我們稱之爲Notes的「後端類」的一部分。這意味着它是代表NSF文件內存版數據的存儲格式的對象之一,這與「前端類」不同。這些對象代表用戶看到和編輯的數據。您可以通過所有前端類的前綴NotesUI從後端類中告知前端。

的事情是,在前端類和後端的對象保持同步除了豐富的文本,這是什麼意思是,確實發生在內存中,您對NotesRichText對象的更改,並保存如果您調用NotesDocument.save(),那麼它們不會反映在屏幕上,除非您從後端重新加載前端數據。這是一個鏈接到wiki page that demonstrates a technique for doing that

+0

我認爲作者已經瞭解後端困難,因爲他的代碼關閉了ui和uiw.EditDocument。 – 2014-09-29 07:26:19

0

你寫了「但它沒有爲我工作」。我試過你的代碼,它的工作原理。我建議你只是爲了一些修改,以使其更好地工作:之前昏暗的身體在RT(後端)與表工作之前 關閉文檔作爲NotesRichTextItem

uidoc.save 'to save any change done 
doc.saveoptions = "0"'to avoid do you want to save 
uidoc.Close True 

到位最後3行:

doc.Save True, True 
Call uiw.EditDocument(True,doc) 

NB你有後添加退出小組「點擊重置演示動作,首先創建表」和「沒有表創建」後

相關問題