Hi !
ich habe ein Script, in dem ich per Klick eine Datei in ein Verzeichnis auf dem PC des Benutzers abspeichern möchte.
Das Verzeichnis liegt auf dem PC im User-Benutzerverzeichnis . Also "c:\users\<benutzername>\Appdata\Local\....
Ich weiß nicht, wie ich die Umgebungsvariable vom Benutzernamen hier einbauen muss ?"
Hab schon diverse Varianten durch. Kommt immer der Fehler, "Path not found".
"C:\Users\%USERNAME%\AppData\Local\IBM\Notes\Data"
"C:\Users\%USER%\AppData\Local\IBM\Notes\Data"
Hat vielleicht jemand eine Idee
Das ist der Code:
Option Public
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim object As NotesEmbeddedObject
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument
Dim downloadfolder As String
Set db = session.CurrentDatabase
Set collection = db.UnprocessedDocuments
downloadfolder = "C:\Users\%USERNAME%\AppData\Local\IBM\Notes\Data"
Print "************************************************************************"
For i = 1 To collection.Count
Set doc = collection.GetNthDocument( i )
filen=Evaluate("@AttachmentNames",doc)
antalfiler=Evaluate("@Attachments", doc)
UserName=db.FileName
Print Str(i)+" ("+Str(collection.count)+")"
If antalfiler(0)>0 Then
For filecounter=0 To antalfiler(0)-1
x=x+1
Print ( filen(filecounter))
Set Object = doc.GetAttachment( filen(filecounter) )
If ( object.Type = EMBED_ATTACHMENT ) Then
fileCount = fileCount + 1
If Dir(downloadfolder+"\"+ filen(filecounter))="" Then
extrachar=""
Else
extrachar=Left(doc.universalid,4)+"---" 'in case attachment with same name exists in several documents
End If
Call object.ExtractFile (downloadfolder+"\"+extrachar+ filen(filecounter) )
Call doc.Save( True, False )
End If
Next filecounter
End If
Next
Msgbox"Es wurden" +Str(fileCount)+ " Dateianhänge auf dem PC im Verzeichnis >\IBM\Notes\Data< gespeichert."
End Sub