看看:
Sub Initialize
Dim workspace As New notesuiworkspace
Dim session As New notessession
Dim db As notesdatabase
Set db=session.currentdatabase
Dim view As notesview
Set view=db.getview("DefaultView")
Dim doc_view As notesdocument
Set doc_view=db.getdocumentbyunid(view.universalid)
If Not doc_view Is Nothing Then
REM //1:Notes文档
REM //2:"关于数据库"文档
REM //4:表单与子表单
REM //8:视图、文件夹与导航器
REM //16:数据库标题
REM //32:设计集合(概要信息)
REM //64:ACL文档(编译格式)
REM //128:未知
REM //256:未知
REM //512:代理
REM //1024:共享域
REM //1548:所有设计元素
Call doc_view.replaceitemvalue("$FormulaClass","4")
Call doc_view.save(True,True)
End If
Dim doc_form As notesdocument
Set doc_form=view.GetFirstDocument
Dim item As notesrichtextitem
Dim obj As notesembeddedobject
Dim filepath As Variant
filepath=workspace.openfiledialog(True,"选择背景图片模板路径","背景图片JPG格式|*.jpg|背景图片GIF格式|*.gif|背景图片BMP格式|*.bmp","D:")
REM Messagebox(Cstr(filepath(0)))
While Not(doc_form Is Nothing)
REM
Forall form In db.Forms
If form.name=doc_form.getitemvalue("$Title")(0) Then
If doc_form.hasitem("$BackgroundR5") Then
Dim item_del As notesitem
Set item_del=doc_form.getfirstitem("$BackgroundR5")
Call item_del.remove
End If
Set item=New notesrichtextitem(doc_form,"$BackgroundR5")
If Isempty(filepath(0)) Then
Call item.appendtext("None")
Else
Set obj=item.EmbedObject(EMBED_ATTACHMENT,"",Cstr(filepath(0)))
REM Set obj=item.EmbedObject(EMBED_OBJECT,"",Cstr(filepath(0)))
End If
Call doc_form.save(True,True)
End If
End Forall
REM
Set doc_form=view.getnextdocument(doc_form)
Wend
End Sub