attachement d'un fichier dans un document notes

Forum destiné aux questions sur le développement : Formules, LotusScript, Java ...

attachement d'un fichier dans un document notes

Messagepar Al » 05 Juin 2003 à 11:06

bonjour,je voudrais faire un programme qui créé un document notes pour chaque fichier trouvé dans le répértoire spécifié.chemain du répertoire:c:\répertoirece répertoire contient des fichiers(word, excel, ....)dans le document Notes j'ai 2 champs :le 1er est de type texte pour récupérer le nom du fichierle 2ème est de type text riche pour attaché le fichier.merci
Al
 

Re: attachement d'un fichier dans un document notes

Messagepar Stephane Maillard » 05 Juin 2003 à 14:36

Bonjour,Voici un code de recherche de fichier à modifier :(Declaration)Private Const MAX_PATH = 260Private Const INVALID_HANDLE_VALUE = -1Private Type FILETIME dwLowDateTime As Long dwHighDateTime As LongEnd TypePrivate Type WIN32_FIND_DATA dwFileAttributes As Long ftCreationTime As FILETIME ftLastAccessTime As FILETIME ftLastWriteTime As FILETIME nFileSizeHigh As Long nFileSizeLow As Long dwReserved0 As Long dwReserved1 As Long cFileName As String * MAX_PATH cAlternate As String * 14End TypeDeclare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" ( _Byval lpFileName As String, _lpFindFileData As WIN32_FIND_DATA) As LongDeclare Function FindNextFile Lib "kernel32" Alias "FindNextFileA" ( _Byval hFindFile As Long, _lpFindFileData As WIN32_FIND_DATA) As LongFunction RechercheFichier(sSearch As String, sFichier As String) As String Dim iNum As Long Dim i As Long Dim iDeb As Long Dim hFile As Long Dim tFindFile As WIN32_FIND_DATA Dim bTrouve As Variant hFile = findfirstfile(sSearch + "\*.*", tFindFile) bTrouve = hFile <> INVALID_HANDLE_VALUE Do While bTrouve If tFindFile.dwFileAttributes = 32 Or tFindFile.dwFileAttributes = 1Then pos = Instr(tfindfile.cfilename, Chr$(0)) tmpSearch = Left$(tfindfile.cfilename, pos - 1) If tmpSearch = sFichier Or tmpSearch = Ucase(sFichier) Then RechercheFichier = sSearch & "\" & tmpSearch Exit Do End If End If inum = inum + 1 bTrouve = FindNextFile(hFile, tFindFile) LoopEnd FunctionExemple :rc = RechercheFichier("C:\Lotus", "unfichier.txt")ourc = RechercheFichier("C:\Lotus", "*.*")msgbox rcAprès vous utilisez un code d'attachement standard.[%sig%]
Cordialement

Stéphane Maillard
Avatar de l’utilisateur
Stephane Maillard
Lord of DominoArea
Lord of DominoArea
 
Message(s) : 8695
Inscrit(e) le : 16 Déc 2004 à 01:10
Localisation : Bretagne

Re: attachement d'un fichier dans un document notes

Messagepar Stephane Maillard » 05 Juin 2003 à 17:32

Re,Voici un code pour l'attachement de document dans un champs RTF, à modifier pour vos besoins :Sub Click(Source As Button) Dim w As New notesuiworkspace Dim s As New NotesSession Dim db As notesdatabase Dim uidoc As notesuidocument Dim view As notesview Dim object As notesembeddedobject Dim doc As notesdocument Dim col As NotesDocumentCollection Dim searchdoc As String Dim DT As New NotesDateTime("1/1/50") Set db = s.currentdatabase Set uidoc = w.currentdocument Dim rtitem As Variant Set doc = uidoc.Document 'Create New RichTextItem in the current document Set rtitem = New NotesRichTextItem(doc,"RT") 'Attach the bitmap Set object = rtitem.EmbedObject ( EMBED_ATTACHMENT, "", "c:\temp\access.txt", "Att" ) 'Get the key value from the current document searchdoc = doc.subject(0) 'Set the form field and save document through backend Doc.Form = "Add Rich Text through UI" Call doc.save(False,False) 'Refresh the main view through back end and front end methods Set view = db.getview("Main") Call view.Refresh Call w.viewrefresh 'Set save options to zero so that user does not get prompted to save after closing uidoc doc.saveoptions = "0" Call uidoc.close 'Open database to main view, find the document again based on searchdoc and open it up Call w.OpenDatabase("","","Main",searchdoc,False,True) Set uidoc = w.Editdocument(True) 'Reset doc and set saveoptions back to "1" Set doc = uidoc.document doc.saveoptions = "1" End Sub[%sig%]
Cordialement

Stéphane Maillard
Avatar de l’utilisateur
Stephane Maillard
Lord of DominoArea
Lord of DominoArea
 
Message(s) : 8695
Inscrit(e) le : 16 Déc 2004 à 01:10
Localisation : Bretagne

Re: attachement d'un fichier dans un document notes

Messagepar Al » 05 Juin 2003 à 19:30

merci
Al
 

Comment lance t'on la fonction RechercheFicier

Messagepar CA39 Bis » 07 Juin 2003 à 06:50

Merci à toi.Je ne n'arrive pas à obtenir de résultat dans rc.J'ai placé le code dans l'agent Sub Terminate rc = RechercheFichier("C:\", "*.*") Msgbox RCEnd Sub
CA39 Bis
 

Re: attachement d'un fichier dans un document notes

Messagepar CA39 » 07 Juin 2003 à 06:52

J'ai mis RC dans Sub Terminate Sub Terminate rc = RechercheFichier("C:\", "*.*") Msgbox RCEnd SubPas de retour RC.Merci encore
CA39
 

variable Sfichier non renseignée

Messagepar CA39 » 07 Juin 2003 à 07:28

J'apprends ..... et cherche à comprendreEn faisant des tests, dans les boucles. J'ai remarqué que cela ne passait pas dans cette boucle car sfichier n'est pas renseigné. If tmpSearch =sfichier Or tmpSearch = Ucase(sFichier) Then RechercheFichier = sSearch & "\" & tmpSearch Par contre je vous bien que je peux recuperer le Nom de Fichier , Neanmoins si tu peux m'éclairer , envoies moi un mail.Encore Merci
CA39
 

Re: attachement d'un fichier dans un document notes

Messagepar Stephane Maillard » 08 Juin 2003 à 18:01

Bonjour,Voici le code de recher de fichier et de création de document avec le nom et le fichier attaché.Personnellement je l'ai mis dans une action :Private Const MAX_PATH = 260Private Const INVALID_HANDLE_VALUE = -1Private Type FILETIME dwLowDateTime As Long dwHighDateTime As LongEnd TypePrivate Type WIN32_FIND_DATA dwFileAttributes As Long ftCreationTime As FILETIME ftLastAccessTime As FILETIME ftLastWriteTime As FILETIME nFileSizeHigh As Long nFileSizeLow As Long dwReserved0 As Long dwReserved1 As Long cFileName As String * MAX_PATH cAlternate As String * 14End TypeDeclare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" (Byval lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As LongDeclare Function FindNextFile Lib "kernel32" Alias "FindNextFileA" (Byval hFindFile As Long, lpFindFileData As WIN32_FIND_DATA) As LongSub Click(Source As Button) Call recherchefichier("C:")End SubFunction RechercheFichier(sSearch As String) As String Dim iNum As Long Dim i As Long Dim iDeb As Long Dim hFile As Long Dim tFindFile As WIN32_FIND_DATA Dim bTrouve As Variant Dim sTmpExt As String Dim sExt(3) As String sExt(0) = "XLS" ' Extension Excel sExt(1) = "PPT" ' Extension PowerPoint sExt(2) = "DOC" ' Extension Winword sExt(3) = "MDB" ' Extension Access hFile = findfirstfile(sSearch + "\*.*", tFindFile) bTrouve = hFile <> INVALID_HANDLE_VALUE Do While bTrouve If tFindFile.dwFileAttributes = 32 Or tFindFile.dwFileAttributes = 1 Then pos = Instr(tfindfile.cfilename, Chr$(0)) tmpSearch = Left$(tfindfile.cfilename, pos - 1) sTmpExt = Right$(Ucase(tmpSearch), 3) Select Case sTmpExt Case sExt(0) RechercheFichier = sSearch & "\" & tmpSearch Call CreationDocument(RechercheFichier, Cstr(tmpSearch)) Case sExt(1) RechercheFichier = sSearch & "\" & tmpSearch Call CreationDocument(RechercheFichier, Cstr(tmpSearch)) Case sExt(2) RechercheFichier = sSearch & "\" & tmpSearch Call CreationDocument(RechercheFichier, Cstr(tmpSearch)) Case sExt(3) RechercheFichier = sSearch & "\" & tmpSearch Call CreationDocument(RechercheFichier, Cstr(tmpSearch)) End Select End If inum = inum + 1 bTrouve = FindNextFile(hFile, tFindFile) LoopEnd FunctionSub CreationDocument(sCheminAndFichier As String, sFichier As String) Dim session As New NotesSession Dim db As NotesDatabase Dim doc As NotesDocument Dim rtitem As NotesRichTextItem Dim object As NotesEmbeddedObject Set db = session.CurrentDatabase Set doc = New NotesDocument( db ) Set rtitem = New NotesRichTextItem( doc, "FichierAttacher" ) Set object = rtitem.EmbedObject(EMBED_ATTACHMENT, "", sCheminAndFichier) doc.Form = "Liste Fichier" doc.NomFichier = sFichier Call doc.Save( True, True )End SubJ'ai un masque qui s'appel Recherche avec deux champs NomFichier en texte standard et FichierAttacher en RichText.[%sig%]
Cordialement

Stéphane Maillard
Avatar de l’utilisateur
Stephane Maillard
Lord of DominoArea
Lord of DominoArea
 
Message(s) : 8695
Inscrit(e) le : 16 Déc 2004 à 01:10
Localisation : Bretagne

Re: attachement d'un fichier dans un document notes

Messagepar Stephane Maillard » 08 Juin 2003 à 18:03

Re,Erratum le masque s'appel 'Liste Fichier'[%sig%]
Cordialement

Stéphane Maillard
Avatar de l’utilisateur
Stephane Maillard
Lord of DominoArea
Lord of DominoArea
 
Message(s) : 8695
Inscrit(e) le : 16 Déc 2004 à 01:10
Localisation : Bretagne

Re: attachement d'un fichier dans un document notes

Messagepar abcc » 09 Juin 2003 à 16:51

Complément pour mettre en oeuvre la procédure...J'ai créé un agent avec l'ensemble du sript,Dans le masque Liste Fichier, j'ai créé une action 'Attache'.J'ouvre le masque et j'appuie sur le bouton.Il me répond que le document n'a pas encotre été enregistré.Alain
abcc
 

Re: attachement d'un fichier dans un document notes

Messagepar Stephane Maillard » 09 Juin 2003 à 19:45

Bonjour,Normal, puisque le code est en back end. Pour l'utilisé dans un masque il faut utilisé les classes Front End.[%sig%]
Cordialement

Stéphane Maillard
Avatar de l’utilisateur
Stephane Maillard
Lord of DominoArea
Lord of DominoArea
 
Message(s) : 8695
Inscrit(e) le : 16 Déc 2004 à 01:10
Localisation : Bretagne

Re: attachement d'un fichier dans un document notes

Messagepar abcc » 09 Juin 2003 à 20:10

Je suis perdu, avec ton explication...
abcc
 

Re: attachement d'un fichier dans un document notes

Messagepar Stephane Maillard » 09 Juin 2003 à 20:21

Re,En LotusScript on peux manipulé les données de deux manières différentes, en back end ou arrière plan ce qui fait que le traitement ne travaille pas sur les données visible à l'écran. Dans le back end on utilise les classes :NotesDocumentNotesDatabaseNotesViewetc...En front end, en avant plan, on ne traite que les données visibles. On utilise les classes suivante :NotesUIDocumentNotesUIDatabaseNotesUIViewDans mon code je ne traite les données en arrière plan.[%sig%]
Cordialement

Stéphane Maillard
Avatar de l’utilisateur
Stephane Maillard
Lord of DominoArea
Lord of DominoArea
 
Message(s) : 8695
Inscrit(e) le : 16 Déc 2004 à 01:10
Localisation : Bretagne

Re: attachement d'un fichier dans un document notes

Messagepar abcc » 09 Juin 2003 à 21:29

Que de chose à apprendre,petit à petit, pourquoi pas...Y a t il des écrits sur tout cel?Bonne semaine
abcc
 

Re: attachement d'un fichier dans un document notes

Messagepar Stephane Maillard » 10 Juin 2003 à 06:22

Bonjour,Malheureusement, il existe beaucoup de livres dans la langue anglaise et aucun en français.Si l'anglais ne vous rebute pas je vous conseil la sélection d'Eyrolles à l'adresse suivante :http://www.eyrolles.com/php.informatique/Ouvrages/liste_ouvrages.php3?noeud_id=1313600&xd=076096ea7a90e0614a585370bfb64f4eOu alors sur les forums en français dédié à Lotus Notes.[%sig%]
Cordialement

Stéphane Maillard
Avatar de l’utilisateur
Stephane Maillard
Lord of DominoArea
Lord of DominoArea
 
Message(s) : 8695
Inscrit(e) le : 16 Déc 2004 à 01:10
Localisation : Bretagne

Suivant

Retour vers Développement