bräuchte mal dringend hilfe. ich will am server objekte in dateianhänge umwandeln.
leider bekomme ich immer beim aktivieren des objektes
Set handle = WObject.activate( False )
die fehlermeldung '4244 - Could not activate embedded object'.
habe es auch ganz einfach mit nem wordpad objekt getestet, damit ich nicht von irgendwelchen applikationen abhängig bin (soll später mit wordpro funktionieren). führe ich das script am client bzw. server-client aus, geht es ohne probleme!!! nur wenn es als agent auf dem server läuft geht es nicht. der server läuft als service. habe auch schon mal von SYSTEM account auf einen anderen account gewechselt. selber fehler.
Dim s As New NotesSession
Dim db As NotesDatabase
Dim v As NotesView
Dim doc As NotesDocument
Dim temp As String
temp = Environ("Temp")
If Not Strright(temp, 1) = "\" Then
temp = temp & "\"
End If
Set db = s.CurrentDatabase
Set v = db.GetView("alle")
Set doc = v.GetFirstDocument
Do While Not doc Is Nothing
Call SmartSuite2MSOffice(doc, temp)
Set doc = v.GetNextDocument(doc)
Loop
Sub SmartSuite2MSOffice(doc As NotesDocument, temp As String)
On Error Goto errorhandle
Dim s As New NotesSession
Dim rtitem As NotesRichTextItem
Dim FileName As String
Dim FilePath As String
Dim FilterType As String
Dim WObject As NotesEmbeddedObject
Dim fileNum As Integer
Dim object_activated As Boolean
Dim handle As Variant
fileCount = 0
fileNum% = Freefile()
Open temp$ & "protokoll.txt" For Output As fileNum%
Set rtitem = doc.GetFirstItem( "Body" )
If ( rtitem.Type = RICHTEXT ) Then
Forall o In rtitem.EmbeddedObjects
object_activated = True
Select Case o.Type
Case EMBED_OBJECT
Print o.name
Set WObject=rtitem.getembeddedobject(o.name)
Print WObject.Class
Print WObject.Source
Print WObject.Filesize
Print WObject.Type
Forall v In WObject.Verbs
Print v
End Forall
Print "set handle start"
'Stop
Set handle = WObject.activate( False )
Print "set handle end"
If object_activated Then
Print "set application"
Set WAObject=handle.application
oclass = WObject.class
Print "object " & oclass
End If
Case EMBED_ATTACHMENT
Set WObject=rtitem.getembeddedobject(o.name)
FileName = temp$ & "tmp\" & WObject.Source
Print FileName
Call WObject.Extractfile(FileName)
macro$ = |@RightBack("| & FileName & |";".")|
ext = Evaluate(macro$)
Select Case Lcase(ext(0))
Case "123"
oclass = "Lotus123.Workbook.98"
Print "attachment " & oclass
Set handle = CreateObject("Lotus123.Workbook.98")
Set WAObject = handle.application
'WAObject.Visible = True
Print "start 123"
WAObject.OpenDocument(FileName)
Case "lwp"
oclass = "WordPro.Document"
Print "attachment " & oclass
Set handle = CreateObject("WordPro.Application")
Set WAObject = handle.application
'WAObject.Visible = True
Print "start wordpro"
WAObject.OpenDocument(FileName)
Case "prz"
oclass = "Freelance.Application.98"
Print "attachment " & oclass
Set handle = CreateObject("Freelance.Application.98")
Set WAObject = handle.application
'WAObject.Visible = True
Print "start freelance"
WAObject.OpenDocument(FileName)
Case Else
oclass = ""
Set handle = Nothing
End Select
Case Else
'ignorieren
End Select
If object_activated Then
If ( o.Type = EMBED_OBJECT) Or (o.Type = EMBED_ATTACHMENT)Then
fileCount = fileCount + 1
Print #fileNum%, "Verarbeite Anhang / Objekt" & fileCount
Print #fileNum%, "Typ: " & oclass
Print #fileNum%, "Source: " & o.Source
pos% = Instr(o.Source, ".")
If pos% > 0 Then
namewoext = Strleftback(o.Source, ".")
Else
namewoext = o.Source
End If
Select Case oclass
Case "WordPro.Document":
FilterType = "MS Word 2000"
FilePath = temp$
FileName = namewoext & Cstr(fileCount) & ".doc"
Print "wordpro save as " & FilterType
WAObject.SaveAs FileName,FilePath , FilterType, False, True, False
WAObject.ApplicationWindow.Close
'kurze warteschleife, da dokument ansonsten noch gesperrt!
x1 = Second(Now())
x = 0
Do While x < 3
'däumchendrehen
x2 = Second(Now())
If x2 < x1 Then
x2 = x2 + 60
End If
x = x2 - x1
Loop
'If ( o.Type = EMBED_OBJECT) Then
WAObject.Quit
'End If
'kurze warteschleife, da dokument ansonsten noch gesperrt!
x1 = Second(Now())
x = 0
Do While x < 3
'däumchendrehen
x2 = Second(Now())
If x2 < x1 Then
x2 = x2 + 60
End If
x = x2 - x1
Loop
Print #fileNum%, "Target: " & FileName
Case "Lotus123.Workbook.98":
tmp_typ = "Excel"
tmp_ext = ".xls"
FileName = namewoext & Cstr(fileCount) & tmp_ext
Print "123 save as " & tmp_typ
WAObject.ActiveDocument.SaveCopyAs(temp$ & FileName)
WAObject.ApplicationWindow.Close(False)
x1 = Second(Now())
x = 0
Do While x < 3
'däumchendrehen
x2 = Second(Now())
If x2 < x1 Then
x2 = x2 + 60
End If
x = x2 - x1
Loop
If ( o.Type = EMBED_OBJECT) Then
Print "close 1-2-3"
WAObject.Quit(False)
Set WAObject = Nothing
End If
Sleep (3)
Print #fileNum%, "Target: " & FileName
Case "Lotus123.Workbook.97":
tmp_typ = "Excel"
tmp_ext = ".xls3"
FileName = namewoext & Cstr(fileCount) & tmp_ext
Print "123 save as " & tmp_typ
WAObject.ActiveDocument.SaveCopyAs(temp$ & FileName)
WAObject.ApplicationWindow.Close
Sleep (3)
If ( o.Type = EMBED_OBJECT) Then
WAObject.Quit
End If
Sleep (3)
Print #fileNum%, "Target: " & FileName
Case "Freelance.Application.98"
FilterType = "MS PowerPoint 97"
tmp_typ = "PowerPoint"
tmp_ext = ".ppt"
FileName = namewoext & Cstr(fileCount) & tmp_ext
Print "freelance save as " & FilterType
WAObject.ActiveDocument.SaveAs FileName, temp$, FilterType
WAObject.ApplicationWindow.Close
Sleep (3)
If ( o.Type = EMBED_OBJECT) Then
WAObject.Quit
End If
Sleep (3)
Print #fileNum%, "Target: " & FileName
Case Else
Print #fileNum%, "Undefinierter Typ!"
End Select
' fileCount = fileCount + 1
' Call o.ExtractFile("h:\temp\olefile" & Cstr(fileCount) )
' Call o.Remove
' Set onew = rtitem.EmbedObject(EMBED_ATTACHMENT, "", tmp_file & tmp_typ & Cstr(fileCount) & tmp_ext)
'Call doc.Save( True, True )
End If
Print #fileNum%, ""
End If
End Forall
End If
Close fileNum%
Exit Sub
errorhandle:
Print Err() & " - " & Error & " at line " & Erl()
Select Case Err()
Case 4244
object_activated = False
Print WObject.Class
Print WObject.Source
Print #fileNum%, Err() & " - " & Error & " at line " & Erl()
Print #fileNum%, WObject.Class
Print #fileNum%, WObject.Source
Print #fileNum%, ""
End Select
Resume Next
End Sub