2022年LOTUS学习技巧 2.pdf
LOTUS 学习技巧三1.我如何在页面上建立一个热点,让它打开一个文档?答: 在页面上写一段文字, 然后选上这段文字, 然后点菜单”创建”热点 - 操作热点然后选 LotusScript ,举个例子 , 比如打开ID 为 NT00000C62的文档 : Sub Click(Source As Button) Dim uiworkspace As New notesuiworkspace Dim curdatabase As notesuidatabase Dim database As notesdatabase Dim doc As notesdocument Set curdatabase = uiworkspace.currentdatabase Set database = curdatabase.database Set doc = database.getdocumentbyid(00000C62) Call uiworkspace.EditDocument(True,doc,False ) End Sub 2.我如何实现归档,比如我如何把当前视图中所有被选中的文档归入文件夹 fold 中?答: 用 Script象如下这样实现: Sub AddDocToFold(fold As String) Dim uiworkspace As New notesuiworkspace Dim uiview As notesuiview Dim doc As NotesDocument Dim docList As String Set uiview = uiworkspace.currentview For j = 1 To uiview.Documents.Count Set doc = uiview.Documents.GetNthDocument(j) Call doc.PutInFolder( fold ) 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 1 页,共 12 页 - - - - - - - - - Next End Sub 3.我如何实现把某文件夹视图中的被选择的文档从该文件夹中清除,但却不能删除他们?答: 用 Script 实现如下 : Sub RemoveDocFromFold( fold As String,all As Integer) 功能: 把文档从某个文件夹中移走,但并不删除此文档 参数: fold: 文件夹 all : 0表示仅移走当前选择的文档,1 表示移走该文件夹中所有文档Dim uiworkspace As New notesuiworkspace Dim uiview As notesuiview Dim doc As NotesDocument Dim view As notesview Set uiview = uiworkspace.currentview Set view = uiview.view If all = 0 Then 移去所选文档For j = 1 To uiview.Documents.Count Set doc = uiview.Documents.GetNthDocument(j) Call doc.RemoveFromFolder( fold ) Next Else If all=1 Then 移去全部文档Set doc = view.GetFirstDocument 遍列该视图的所有文档, 获取所有满足条件的纪录数名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 2 页,共 12 页 - - - - - - - - - While Not(doc Is Nothing) Call doc.RemoveFromFolder( fold ) Set doc = view.GetNextDocument(doc) Wend End If End If Evaluate(Command(ViewRefreshFields) End Sub 4.我如何把当前视图中的所有的被选择的文档的某个域的值替换掉?答: 用 Script 实现如下 : Sub SelectedDocFieldReplace( Field As String,repval As String) 功能: 把所选文档中的每个 Field 域的值改为 repval 参数: Field 要更改的域的名称 repval 修改后的域值Dim uiworkspace As New notesuiworkspace Dim uiview As notesuiview Dim doc As NotesDocument Dim order_num As String order_num = Inputbox$(请输入批次 ) Set uiview = uiworkspace.currentview For j = 1 To uiview.Documents.Count Set doc = uiview.Documents.GetNthDocument(j) On Error Goto lable1 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 3 页,共 12 页 - - - - - - - - - Call doc.replaceitemvalue(Field,repval) Call doc.save(True,False) Next Exit Sub lable1: Msgbox( 错误!,所选文档没有指定的域,这个错误发生在没有给selectedDocFieldReplace() 函数传递正确的参数) Exit Sub End Sub 5.我如何创建某个程序运行结果的日志文档?6.答: 首先新建一个日志文档的表单, 并把该表单设置成数据库的默认表单, 然后就用 Script 创建文档 , 并填写该文档中某些域的值, 最后存盘 , 例子程序片段如下: 写传真日志Dim faxerdoc as notesdocument faxerr_receiver,faxerr_docnum,faxerr_content是表单 form_faxerr的三个域名Set faxerrdoc = New NotesDocument( db ) faxerrdoc.Form = form_faxerr Call faxerrdoc.replaceitemvalue(faxerr_receiver,Cstr(peoplecount) ) Call faxerrdoc.replaceitemvalue(faxerr_docnum,strsucssnding ) Call faxerrdoc.replaceitemvalue(faxerr_content,faxerrmsg ) success = faxerrdoc.ComputeWithForm( False, False ) If success Then Call faxerrdoc.Save( True, False ) Else 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 4 页,共 12 页 - - - - - - - - - Msgbox( 无法写入传真日志.) End If Msgbox(faxerrmsg) Exit Sub 7.我要从当前视图中选择一批文档,并让程序从这些文档中提取信息,在嵌入在表单中的 OLE 对象 Word 文档中建立一张表,要求是选择了几篇文档就在这张表中画几行,这张表的每个列的信息都中文档中的域中提取,换句话说 ,就是要把被选文档以Word 文档表格的形式表示出来,能否给我一个这方面的例子程序?8.答: 可以 ,下面就是这样的一个例子: Sub inputgroupplan(source As notesuidocument,doccollection As notesdocumentcollection) 功能:自动生成出团计划表。 详细描述: 从 文档集合 doccollection 中提取各个域值,并把提取的信息以一定 的表格形式送入当前文档的 body 域中的 OLE 对象 -Word 文档中 . 参数: source: 当前文档 doccollection :文档集(比如文档的选择集) 编写: 商云方 完成日期: Dim session As New NotesSession 当前会话Dim counter As Integer 计数器Dim doccustom As NotesDocument notes 文档对象Dim thisdoc As Variant Word 文档对象Dim thisrange As Variant Word 开发中的 range 对象名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 5 页,共 12 页 - - - - - - - - - Dim thispicture As Variant 嵌入 Word 文档的图象对象Dim thistable As Variant 嵌入 Word 文档的表格对象Dim pagehead As String 嵌入 Word 标题 获取嵌入文档的句丙If source.EditMode Then Set thisdoc = source.getobject(oleobject) 插入一幅图学习 cassiatb.jpg) 设置图像属性With thispicture.wrapformat 环绕方式.type = wdwrappicture 类型为 picture .side = wdwrapright 文字右环绕End With 设置该文档的页面设置的左边距为20 个单位 ( 象素 ) With thisdoc.pagesetup .leftmargin = 20 .rightmargin = 20 End With counter=0 pagehead = Inputbox$(请输入标题 ) pagehead = Chr(10) & pagehead & Chr(10) & Chr(10) & Chr(10) Call source.FieldSetText ( Namelist_Group_Num, group_num ) groupstring = Namelist & & group_num & Chr(10) Set thisrange = thisdoc.range(1,1) thisrange.InsertBefore (pagehead) 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 6 页,共 12 页 - - - - - - - - - Set thisrange = thisdoc.range(2,Len(pagehead) With thisrange .bold = True 加粗.ParagraphFormat.Alignment = 1wdAlignParagraphCenter 行居中.font.size = 20 字体大小为20 End With Set doccustom = doccollection.GetFirstDocument 遍列文档集的所有文档, 获取所有满足条件的纪录数While Not(doccustom Is Nothing) counter=counter+1 Set doccustom = doccollection.GetNextDocument(doccustom) Wend 动态分配纪录数组Redim record(counter,6) As String 插入一张表Set thisrange = thisdoc.range(Len(pagehead)+1,Len(pagehead)+1) Set thistable = thisdoc.tables.Add(thisrange, counter+1, 8) thistable.autoformat(False) 写表头thistable.rows(1).cells(1).range.insertbefore(前往国家 ) thistable.rows(1).cells(2).range.insertbefore(国家数 ) thistable.rows(1).cells(3).range.insertbefore(天数 ) thistable.rows(1).cells(4).range.insertbefore(出境城市 ) thistable.rows(1).cells(5).range.insertbefore(入境城市 ) thistable.rows(1).cells(6).range.insertbefore(出发日期 ) 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 7 页,共 12 页 - - - - - - - - - thistable.rows(1).cells(7).range.insertbefore(同行价 ) thistable.rows(1).cells(8).range.insertbefore(市场指导价 ) 恢复计数器counter = 0 写表内容Set doccustom = doccollection.GetFirstDocument While Not(doccustom Is Nothing) counter = counter+1 thistable.rows(counter+1).cells(1).range.insertbefore(doccustom.plan_country(0) thistable.rows(counter+1).cells(2).range.insertbefore(doccustom.plan_country_num(0) thistable.rows(counter+1).cells(3).range.insertbefore(doccustom.plan_day(0) thistable.rows(counter+1).cells(4).range.insertbefore(doccustom.plan_out_city(0) thistable.rows(counter+1).cells(5).range.insertbefore(doccustom.plan_in_city(0) thistable.rows(counter+1).cells(6).range.insertbefore(doccustom.plan_date(0) thistable.rows(counter+1).cells(7).range.insertbefore(doccustom.plan_whole_price(0) thistable.rows(counter+1).cells(8).range.insertbefore(doccustom.plan_mart_price(0) Set doccustom = doccollection.GetNextDocument(doccustom) Wend End If End Sub 9.如何实现表单上的内容根据用户的输入动态变化?名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 8 页,共 12 页 - - - - - - - - - 答: 一般可以用notes 的隐藏属性功能来控制, 使用当公式为真是隐藏, 然后靠公式来控制具体怎样隐藏. 比如可以在对话筐上放一个对话筐列表, 里面放十个选项, 当用户选择了其中的某几个选项时, 响应的在下面的表单部分显示几行. 这可以画一个表格 , 这个表格的属性中设置边框的线条粗细为零. 然后对应十个选项分为十行, 每行填入和选项响应的内容, 然后选定某一行的所有文本, 编辑其隐藏属性, 选当公式为真时隐藏 , 这个公式您就可以写成当选项的被选中条目中不包含本行文字时隐藏就可以了 ,这样这一行就会在响应的选项被选中时才会显示. 10. notes没有应用程序级的公共变量,那么我如果要弹出一个对话筐,并从这个对话筐中返回很多用户输入,我该怎么办 ?怎样判断视图中没有文档?dim uiw as new notesuiworkspace dim doc as notesdocument set doc = uiw.getfirstdocument() if doc is nothing then . end if 如何将查询结果放到一个文件夹里?下面是将搜索结果放到名叫newfolder的文件夹中,并跳转到该文件夹上Sub Click(Source As Button) dim uiw as new notesuiworkspace dim uidoc as notesuiworkspace dim doc as notesdocument set uidoc = uiw.currentdocument set doc = uidoc.document dim ss as new notessession dim db as notesdatabase set db = ss.currentdatabase const newfolder = 文件夹名称 Dim docs As notesdocumentcollection q=doc.query(0) Set docs = db.ftsearch(q, 0) Call docs.PutAllInFolder( newfolder ) Call uiw.OpenDatabase( ,newfolder) End Sub 如何在 Notes 中调用 ODBC 数据源中的进程?Dim session As New NotesSession Dim con As New ODBCConnection Dim qry As New ODBCQuery 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 9 页,共 12 页 - - - - - - - - - Dim result As New ODBCResultSet Set qry.Connection = con Set result.Query = qry con.ConnectTo( 资料库 ) qry.SQL = SELECT * FROM 资料库result.Execute If result.IsResultSetAvailable Then Do result.NextRow id=result.GetValue(ID,id) Loop Until result.IsEndOfData result.Close(DB_CLOSE) Else Messagebox Cannot get result set for AssetData Exit Sub End If con.Disconnect End Sub 从后台刷新当前文档?将当前文档先关闭后再打开set doc=uidoc.document . call uidoc.save() call uidoc.close() set uidoc=ws.editdocument(doc) 获得当前视图中选择了的文档?可以用 Notesdatabase 的 Unprocesseddocuments 属性。Dim session As New notessession Dim db As notesdatabase Dim collection As notesdocumentcollection Set db = session.currentdatabase Set collection = db.UnprocessedDocuments Unprocesseddocuments 其实很有用的notes 和 Excel 交换数据Dim session As New NotesSession Dim db As NotesDatabase Dim view As NotesView Dim doc As NotesDocument Dim excelApplication As Variant Dim excelWorkbook As Variant Dim excelSheet As Variant Dim i As Integer 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 10 页,共 12 页 - - - - - - - - - Set excelApplication = CreateObject(Excel.Application) excelApplication.Visible = True Set excelWorkbook = excelApplication.Workbooks.Add Set excelSheet = excelWorkbook.Worksheets(Sheet1) excelSheet.Cells(1,1).Value = 姓名excelSheet.Cells(1,2).Value = 年龄i = 1 Set db = session.CurrentDatabase Set view = db.GetView(abc) Set doc = view.GetFirstDocument While Not(doc Is Nothing) i = i + 1 excelSheet.Cells(i,1).Value = doc.ClassCategories(0) excelSheet.Cells(i,2).Value = doc.Subject(0) Set doc = view.GetNextDocument(doc) Wend excelSheet.Columns(A:B).Select excelSheet.Columns(A:B).EntireColumn.AutoFit excelWorkbook.SaveAs(Script 内容 ) excelApplication.Quit Set excelApplication = Nothing 在视图中怎样历遍所有的文档?Dim db As New NotesDatabase( Ankara, currentprojects.nsf ) Dim view As NotesView Dim doc As NotesDocument Set view = db.GetView( OpenBy Due Date ) Set doc = view.GetFirstDocument While Not ( doc Is Nothing ) . Set doc = view.GetNextDocument( doc ) Wend 在 scipt中如何调用公式例如我们想要取服务器名的普通名,在script中用 name() , 假设 server变量以取到服务器名称在 script中用 Evaluate可以运行公式,如:servername=Evaluate(name(CN;server) 怎样用 script代理取到CGI变量Dim session As New NotesSession Dim doc As NotesDocument Set doc = session.DocumentContext Messagebox User = + doc.Remote_User(0) 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 11 页,共 12 页 - - - - - - - - - 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 12 页,共 12 页 - - - - - - - - -