Rehi
mein Script läuft jetzt aber ab und zu (ich kann der Grund nicht erkennen) läuft auf Fehler...
....
If Not doc.HasEmbedded Then Exit Sub
Set Item = doc.GetFirstItem("Anhang")
If Item.Type = RICHTEXT Then
Forall att In Item.EmbeddedObjects
...
In dem Feld ist definitiv 1 Anhang aber ab und zu kommt die Fehlermeldung "Type mismatch" ohne weitere Kommentar.
Schon mal gehabt?
Ich habe eine Kopie vom Dokument gemacht, wo ein Datei im Feld Anhang steht
Wenn ich den Debugger mit F5 laufe lasse kommt die Meldung direkt auf den Zeile
Forall att In Item.EmbeddedObjects
Mit F8 kein Fehler
Ich habe schon ein sleep davor eingetragen, bringt allerdings nichts ::)
hier mehr Info:
erste Teil lösche ich die Anhänge und füge sie wieder ein nach Hochzählen.
PKI Signatur wird gelöscht
'PKI Signatur löschen
Call doc.RemoveItem("SecSig")
Call doc.Save( True , True )
'Abhängen und anhängen
Set Item = doc.GetFirstItem("Anhang")
If Item.Type = RICHTEXT Then
Forall att In Item.EmbeddedObjects
If att.Type = EMBED_ATTACHMENT Then
filepath$ = "C:\temp\" & att.Source
Call att.ExtractFile(filepath$)
'Hochzählen
fileNumber = Mid(filepath$, Instr(filepath$, "-")+1, 3)
filenumber = Right("000" + Cstr(Cint(fileNumber) +1 ),3)
fileLeft = Left(filepath$, Instr(filepath$, "-"))
fileRight = Right(filepath$, Len(filepath$) - Instr(filepath$, ".") + 1)
fileNewpath = fileLeft + fileNumber + fileRight
Name filepath$ As fileNewpath
filepath$ = fileNewPath
Call doc.RemoveItem("Anhang")
Call doc.Save( True , True )
Set rtitem = New NotesRichTextItem( doc, "Anhang" )
Set object = rtitem.EmbedObject( EMBED_ATTACHMENT, "", filepath$ )
Kill filepath$
End If
End Forall
End If
rc = SigWithSecCom(doc)
...
Zweite starte ich die PKI Signature für jeden Dokument
Function SigWithSecCom(doc As NotesDocument) As Integer
Dim Item As NotesRichTextItem
Dim Item1 As NotesRichTextItem
Dim object As NotesEmbeddedObject
Dim object1 As NotesEmbeddedObject
Dim rc As Boolean
Dim TaskID As Variant
Dim strCmd As String
Dim filepath As String
If Not doc.HasEmbedded Then Exit Function
Set Item = doc.GetFirstItem("Anhang")
REM Get attachments
If item.Type = RICHTEXT Then
Sleep 3
'---> hier kommt der Fehler
Forall o In Item.EmbeddedObjects
If ( o.Type = EMBED_ATTACHMENT ) Then
filepath$ = "C:\temp\" & o.Source
Call o.ExtractFile(filepath$)
Msgbox filepath$ & " wird signiert"
strCmd = SecProg + " " + filepath$
TaskID = Shell( strCmd, 1)
Sleep 10
rc = True
While rc = True
Sleep 1
rc = IsProcessRunningW2K ( "SecSigner" )
Wend
Call doc.RemoveItem("Anhang")
Set Item = New NotesRichTextItem( doc, "Anhang" )
Set object = Item.EmbedObject( EMBED_ATTACHMENT, "", filepath$ )
Kill filepath$
Set Item1 = doc.GetFirstItem("SecSig")
Call doc.RemoveItem("SecSig")
Set Item1 = New NotesRichTextItem( doc, "SecSig" )
Set object1 = Item1.EmbedObject( EMBED_ATTACHMENT, "", filepath$ + ".pkcs7")
Kill filepath$ + ".pkcs7"
Call doc.Save( True , True )
End If
End Forall
End If
SigWithSecCom = 1
End Function
komischerweise, in der Postsave läuft Notes durch ohne Fehler.
Bei wieder nehmen der Anhänge in der SicWithSecCom Function kommt es zu diese "Type mismatch" Fehler.
Wenn ich mir Item anschaue in Debuger, hat er die EmbededObjects.