Hello tout le monde, et merci beaucoup de m'aider.


Voila, cela fait quelques heures que je cherche.. en vain..


Et pourtant, je suis certain que cela ne doit pas etre compliqué.

Voici ce qui me pose probleme:

Je voudrais en VBA, grace à l'automation excel, ouvrir une feuille définie(son nom: 3.1.unif institution unif) d'un classeur non vide(son nom est dans la variable: XlFilename) , la modifier, et l'enregistrer dans le meme classeur sous un autre nom.

Pour le moment, j'ai ceci:


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 
    Dim xlApp As Excel.Application
    Dim xlBook As Excel.Workbook
    Dim xlSheet As Excel.Worksheet
 
    Set xlApp = CreateObject("Excel.Application")
 
Set xlBook = xlApp.Workbooks.Open(Application.CurrentProject.Path & "\" & XlFilename & ".xls")
 
For I = 0 To UBound(nomInst())
           Set xlSheet = xlBook.Sheets("3.1.unif institution unif")
           xlSheet.Activate
           xlSheet.Name = "3.1.unif institution unif" & nomInst(I)
           xlSheet.Copy After:=Worksheets("3.1.unif institution unif")
           xlSheet.Cells(LIG1 + 3, COL1 + 1) = nomInst(I)
 
         Next
 
 
  xlBook.Save
      xlBook.Close
      xlApp.Quit