Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
mahieuphilippe
Creator
Creator

Comment créer plusieurs feuilles Excel en exportant via une variable

Bonjour à tous,

J'ai déjà regardé dans le forum pour la réponse mais ce n'est pas clair pour moi petit novice ....

Actuellement j'ai une commande qui exporte plusieurs objets dans Excel qui fonctionne bien mais qui exporte tous mes tableaux

dans le même feuille 'Feuil1"

Je voudrais lors de l'exportation, qu'il renomme la 'feuil1' par la date de l'exportation (25092017)

est possible ?

ma deuxième demande :   est-il possible d'exporter les deux premiers objet dans la feuil1  et les autres dans la feuil 2 ?

voici le script

Sub ExcelExpwCaption

     'Set the path where the excel will be saved

    

    

   filePath =  "O:\04 FSR - PLANIFICATION\FSR - Suivi Journalier\test.xlsx"

    

    ' filePath = "C:\Users\nm36505\Desktop\SD QV\test.xlsx"

     'Create the Excel spreadsheet

     Set excelFile = CreateObject("Excel.Application")

     excelFile.Visible = true

     'Create the WorkBook

     Set curWorkBook = excelFile.WorkBooks.Add

     'Create the Sheet

     Set curSheet = curWorkBook.WorkSheets(1)

    

    

    

    

     'Get the chart we want to export

     Set tableToExport = ActiveDocument.GetSheetObject("CH16")

     Set chartProperties = tableToExport.GetProperties

     tableToExport.CopyTableToClipboard true

     'Get the caption

     chartCaption = tableToExport.GetCaption.Name.v

     'MsgBox chartCaption

     'Set the first cell with the caption

     curSheet.Range("A1") = chartCaption

     'Paste the rest of the chart

     curSheet.Paste curSheet.Range("A2")

    

    

      Set tableToExport = ActiveDocument.GetSheetObject("CH19")

     Set chartProperties = tableToExport.GetProperties

     tableToExport.CopyTableToClipboard true

     'Get the caption

     chartCaption = tableToExport.GetCaption.Name.v

     'MsgBox chartCaption

     'Set the first cell with the caption

     curSheet.Range("J1") = chartCaption

     'Paste the rest of the chart

     curSheet.Paste curSheet.Range("J2")

    

    

         Set tableToExport = ActiveDocument.GetSheetObject("CH18")

     Set chartProperties = tableToExport.GetProperties

     tableToExport.CopyTableToClipboard true

     'Get the caption

     chartCaption = tableToExport.GetCaption.Name.v

     'MsgBox chartCaption

     'Set the first cell with the caption

     curSheet.Range("L1") = chartCaption

     'Paste the rest of the chart

     curSheet.Paste curSheet.Range("L2")

    

    

      

         Set tableToExport = ActiveDocument.GetSheetObject("TP")

     Set chartProperties = tableToExport.GetProperties

     tableToExport.CopyTableToClipboard true

     'Get the caption

     chartCaption = tableToExport.GetCaption.Name.v

     'MsgBox chartCaption

     'Set the first cell with the caption

     curSheet.Range("N1") = chartCaption

     'Paste the rest of the chart

     curSheet.Paste curSheet.Range("N2")

    

    

    

    

       excelFile.Visible = true

     'Save the file and quit excel

     curWorkBook.SaveAs filePath

     curWorkBook.Close

     excelFile.Quit

     'Cleanup

     Set curWorkBook = nothing

     Set excelFile = nothing

End Sub

d'avance merci

0 Replies