Das Notes Forum

Domino 9 und frühere Versionen => ND8: Entwicklung => Thema gestartet von: platzebo am 20.01.12 - 08:08:44

Titel: HowTo designReplace per LotusScript
Beitrag von: platzebo am 20.01.12 - 08:08:44
falls mal jemand eine Schablone per Knopfdruck wechseln möchte...  ;D

Declare Sub W32_OSPathNetConstruct Lib "nnotes.dll" Alias "OSPathNetConstruct" (Byval portName As String, Byval ServerName As String, Byval FileName As String, Byval retPathName As String)

Declare Function W32_NSFDbOpen Lib "nnotes.dll" Alias "NSFDbOpen" ( Byval szDBName As String, dwDBHandle As Long) As Integer

Declare Function W32_NSFDbClose Lib "nnotes.dll" Alias "NSFDbClose" ( Byval dwDBHandle As Long) As Integer

Declare Function W32_DesignReplace Lib "nnotes.dll" Alias "DesignReplace" (Byval ht As Long, Byval hDB As Long, Byval dw1 As Long, Byval dw2 As Long, Byval dw3 As Long, Byval dw4 As Long) As Integer


Function ReplaceDesign(TemplDB As NotesDatabase, TargetDB As NotesDatabase) As Integer
   
        on error goto errHandle

   Dim PathName As String * 256
   Dim TargetPathName As String * 256
   
   Dim htemplate As Long
   Dim htarget As Long
   
   Dim DBDocPropTempl As NotesDocument
   Dim DBDocPropTarget As NotesDocument

   ReplaceDesign = false

   Call W32_OSPathNetConstruct("", TemplDB.Server, TemplDB.FilePath, PathName)
   Call W32_OSPathNetConstruct("",TargetDB.Server, TargetDB.FilePath,TargetPathName)
   
   Call W32_NSFDbOpen(PathName, htemplate)
   If htemplate=0 Then Exit Function
   Call W32_NSFDbOpen(TargetPathName, htarget)
   If htarget=0 Then Exit Function
   
   Call W32_DesignReplace(htemplate, htarget, 1, 1, 0, 0)
   
   Call W32_NSFDbClose(htemplate)
   Call W32_NSFDbClose(htarget)
   
   Set DBDocPropTempl = TemplDB.GetDocumentByID("FFFF0010")
   Set DBDocPropTarget = TargetDB.GetDocumentByID("FFFF0010")
   Call DBDocPropTempl.CopyAllItems(DBDocPropTarget)
   Call DBDocPropTarget.Save(True, False)

        ReplaceDesign = true
   exit function

errHandle:
        msgbox cstr(err) + " : " + error + " in Line " + cstr(erl)
        exit function
End Function
Titel: Re: HowTo designReplace per LotusScript
Beitrag von: pram am 21.01.12 - 13:52:39
Achtung,  bei copyallitems unbedingt replace=true als 2. Parameter setzen,  sonst hat man die items dpppelt.
Gruß Roland
Titel: Re: HowTo designReplace per LotusScript
Beitrag von: platzebo am 23.01.12 - 06:48:28
Danke für den Tip und einen guten Wochenstart :)