Lotus Notes / Domino Sonstiges > Tools & Downloads

Autom. Speichern Attachements u. Programm starten

<< < (2/3) > >>

eknori (retired):
Ja, du müsstest einen Hotspot in das Doc einfügen

file://c:\temp\meineDatei.xyz

Hardy:
Is klar, aber wie geht das mit LotusScript bezogen
auf den Code ?

Hardy

eknori (retired):
JAAAAA, das ist das grosse Geheimnis. Ehrlich gesagt, ich weiss es nicht. Habe schon mal bei Notes.net geschaut, aber da weiss auch keiner Bescheid. :-X
Ich habe momentan auch keine grosse Lust, mich durch die Lotus Notes API zu wühlen  :P

Was mir noch so als Möglichkeit vorschwebt, ist per script einen button in das Dokument zu kopieren ( AppendRTItem) der den Code aus meiner Reattach.nsf enthält. Die Ablageorte für das/die Attachments kann man dann in ein verstecktes Feld schreiben. der Code liest das Feld und baut ein PopUp auf, aus dem der User das Attachment auswählen kann, das er starten will.

Wenn ich dazu komme, mache ich das mal übers WE

eknori

Hardy:
Wäre "EmbedObject method" nicht eine Möglichkeit
als object link ?

Hardy

eknori (retired):
So, Wochenende vorbei. Hab's fertig:

Von wegen API und so ein Schnick Schnack; einfach mal ein bisschen rumprobiert und schon gehts

Man kann ja automatisch einen Hotspot erstellen, wenn man im RT Feld eingibt

http://www.undsoweiterde....

wenn man dann im Lesemodus das Dokument öffnet, kann man den Link anklicken und die Seite wird aufgerufen.

Analog kann man das ja auch mit File:// machen... hatte ich gadacht. Aber dann stand nur der Text im Feld.
Hätte ich doch nur vorher mal statt // einfach \\ eingegeben  :-[ :-[

Hier also der komplette Code noch einmal in der richtigen Fassung.

Der Pfad zum Abspeichern darf KEINE Leerzeichen enthalten. Und, bei mir wird immer erst der Netscape Navigator gestartet. Ist möglicherweise eine Systemeinstellung.

So, viel Spass beim Probieren

euer eknori

'Download Attachments:

Option Public

Sub Initialize
     
     Dim session As New NotesSession
     Dim db As NotesDatabase
     Dim doc As NotesDocument
     Dim dc As NotesDocumentCollection
     Dim answer As Integer
     Dim rtitem As Variant
     Dim attachname As String
     Dim filename As String
     Dim extension As String
     Dim checkname As String
     Dim newname As String
     Dim x As Integer
     
     On Error Resume Next
     Mkdir "c:\temp"
'      Mkdir "c:\My Documents\Notes Attachments"
     
     Set db = session.CurrentDatabase
     Set dc = db.UnprocessedDocuments
     Set doc = dc.GetFirstDocument
     x = 0
     
     Do Until Doc Is Nothing
           Set rtitem = doc.GetFirstItem( "Body" )
           
' Goes to the body field and finds all attachments
           If ( rtitem.Type = RICHTEXT ) Then
                 Forall obj In rtitem.EmbeddedObjects
                       If ( obj.Type = EMBED_ATTACHMENT ) Then
' If a duplicate file name is found, ask the user whether they would like to overwrite , update name, or cancel entire operation
                             If( Dir$("c:\temp\" & obj.Source)) <> "" Then
                                   attachname = obj.source
                                   answer = Msgbox ("This folder already contains a file named " & attachname & ". " & Chr(10) & "Would you like to create a new file name for this file in the format 'filenameX'? " & Chr(10) & Chr(10) & "If you choose yes, a new file name will be created. " & Chr(10) & "If you choose no, the file will be overwritten with this attachment. " & Chr(10) & "The cancel button will stop the download process for the rest of the selected documents." , 547, "Warning!" )
                                   
' 2= cancel, 7= No (overwrite), 6= Yes (update name)
                             Else
                                   attachname = obj.source
                                   Call obj.ExtractFile( "c:\temp\" & attachname )
                                   Call obj.Remove
                                   Call rtitem.AddNewLine( 2 )
                                   Call rtitem.AppendText(( "Your file was downloaded to File:\\c:\temp\" ) & attachname)
                                   Call doc.Save( False, True )
                                   answer = 0
                             End If
                             
                             If( answer = 2 ) Then ' User has chosen to cancel
                                   
                                   Exit Sub
                                   
                             End If
                             
                             If( answer = 7 ) Then ' User has chosen to overwrite existing file
                                   
' Downloads file name and overwrites the attachment with the same name
                                   Call obj.ExtractFile( "c:\temp\" & attachname )
                                   Call obj.Remove
                                   Call rtitem.AddNewLine( 2 )
                                   Call rtitem.AppendText(( "Your file was downloaded to File:\\c:\temp\" ) & attachname)
                                   Call doc.Save( False, True )
                                   answer = 0
                                   
                             End If
                             
                             If( answer = 6 ) Then ' User has chosen to download with new name
                                   
' Gets everything to the left and right of the file name and puts them in variables
                                   filename = sLeft( attachname, "." )
                                   extension = "." & sRight( attachname, "." )
                                   
                                   newname = attachname
                                   
' Loop until you find unique file name - Dir command returns "" if file name is not found in specified directoty
                                   Do While (Dir$("c:\temp\" & newname)) <> ""
' Adds next sequential number to the end of the file name - then puts them all together as newname
                                         x=x+1
                                         newname = filename & Cstr(x) & extension
                                   Loop
                                   
' Once you have unique file name - download with new name
                                   Call obj.ExtractFile( "c:\temp\" & newname )
                                   Call obj.Remove
                                   Call rtitem.AddNewLine( 2 )
                                   Call rtitem.AppendText(( "Your file was downloaded to File:\\c:\temp\" ) & newname)
                                   Call doc.Save( False, True )
                                   answer = 0
                             End If
                       End If
                       
                 End Forall
           End If
           answer = 0
           Set doc = dc.GetNextDocument(doc)
     Loop
End Sub


Function sLeft ( sourceString As String, searchString As String ) As String
     
     pos% = Instr ( sourceString, searchString )
     If pos% > 0 Then pos% = pos% -1
     sLeft = Left ( sourceString, pos%)
     
End Function

Function sRight ( sourceString As String, searchString As String) As String
     
     pos% = Instr ( sourceString, searchString )
     length% = Len ( sourceString )
     start% = length% - pos%
     sRight = Right ( sourceString, start% )
     
End Function

Navigation

[0] Themen-Index

[#] Nächste Seite

[*] Vorherige Sete

Zur normalen Ansicht wechseln