par Raziel » 27 Mai 2003 à 07:07
Salut, voici un code que j'ai donné à l'époque pour une exportation excelCe dernier scan ma vue inbox afin de récupérer toutes les colonnes non cachées et ayant un titre. Ensuite il me fait apparaitre une petite fenêtre me permettant de sélectionnez les colonnes que je veux exporter.CODE :---------Sub InitializeDim Session As New notessessionDim ws As New notesuiworkspaceDim db As notesdatabaseDim Vue As notesviewDim NomCol() As StringDim TabCol As VariantDim Indice As IntegerSet db = Session.currentdatabaseSet Vue = db.getview("($Inbox)")Redim NomCol(Ubound(Vue.Columns)) As StringIndice = 0Forall Colonne In Vue.ColumnsIf Colonne.Title <> "" And Colonne.IsHidden = False Then NomCol(indice) = Colonne.Title + "|" + Str$(Indice)Indice = Indice + 1End ForallTabCol = ws.Prompt(PROMPT_OKCANCELLISTMULT, "Exportation vers Excel", _"Sélectionnez les colonnes à exporter","" , Fulltrim(NomCol))If Not Isempty(TabCol) ThenFor indice = 0 To Ubound(TabCol)TabCol(Indice) = Trim(Right(TabCol(Indice), 2))NextCall ExtractNotesToExcel(Vue, TabCol)End IfEnd SubSub ExtractNotesToExcel (Vue, TabCol As Variant)Dim Doc As notesdocumentDim Valeur As VariantDim xlApp As VariantDim Ligne As IntegerDim Colonne As IntegerDim IndiceTab As IntegerSet Doc = Vue.getfirstdocumentIf Not Doc Is Nothing Then' Création de l'objet ExcelSet xlApp = createObject("Excel.sheet")' Création du classeur ExcelxlApp.Application.Workbooks.add' Création d'une page avec renommagexlApp.Application.Sheets.addxlApp.Application.Sheets(xlApp.Application.activesheet.name).Name = "Exportation vue Notes"End If Ligne = 1While Not Doc Is NothingColonne = 1For IndiceTab = 0 To Ubound(TabCol)Valeur = Doc.ColumnValues(Val(TabCol(IndiceTab)))xlApp.Application.activesheet.Cells(Ligne,Colonne).Value = ValeurColonne = Colonne + 1Next' Passage au doc suivantSet Doc = Vue.getnextdocument(Doc)Ligne = Ligne + 1Wend' On rend le classeur Excel visiblexlApp.application.visible= True' Enregistrement du docxlApp.Application.activesheet.SaveAs "C:\Temp\Classeur2.xls"End Sub
Raziel
L'administration est un lieu ou les gens qui arrivent en retard croisent dans l'escalier ceux qui partent en avance. [Georges Courteline]