LOTUS学习技巧 三

来源:互联网 发布:西太平洋银行内部数据 编辑:程序博客网 时间:2024/04/29 15:51

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 )
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
'遍列该视图的所有文档,获取所有满足条件的纪录数
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
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
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 对象
Dim thispicture As Variant '嵌入Word 文档的图象对象
Dim thistable As Variant '嵌入Word 文档的表格对象
Dim pagehead As String '嵌入Word 标题
'获取嵌入文档的句丙
If source.EditMode Then
Set thisdoc = source.getobject("oleobject"
'插入一幅图
Set thispicture = thisdoc.shapes.Addpicture("c:/学习/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)
Set thisrange = thisdoc.range(2,Len(pagehead))
With thisrange
.bold = True '加粗
.ParagraphFormat.Alignment = 1'wdAlignParagraphCenter 行居中
.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,
'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("出发日期")
thistable.rows(1).cells(7).range.insertbefore("同行价")
thistable.rows(1).cells(.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(.range.insertbefore(doccustom.plan_mart_price(0))
Set doccustom = doccollection.GetNextDocument(doccustom)
Wend
End If
End Sub
9.        如何实现表单上的内容根据用户的输入动态变化?

答: 一般可以用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
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

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, current/projects.nsf )
Dim view As NotesView
Dim doc As NotesDocument
Set view = db.GetView( Open/By 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)

 

原创粉丝点击