Ouvrir un fichier a l'aide bouton vb

Résolu
DERAZ -  
 derch -
Bonjour,
j'ai un travail sur un fichier excel ,je veux l'ouvrir a laide d'un bouton en vb6 .je cherche un code mais j'ai pas trouver.

1 réponse

  1. Lord Zero Messages postés 487 Statut Membre 115
     
    Private Sub Command1_Click() 
    'Déclaration des variables 
     Dim appExcel As Excel.Application 'Application Excel 
     Dim wbExcel As Excel.Workbook 'Classeur Excel 
     Dim wsExcel As Excel.Worksheet 'Feuille Excel 
      
    'Ouverture de l'application 
     Set appExcel = CreateObject("Excel.Application") 
     'Ouverture d'un fichier Excel 
     Set wbExcel = appExcel.Workbooks.Open("chemin+fichier.xls") 
    'wsExcel correspond à la première feuille du fichier 
     Set wsExcel = wbExcel.Worksheets(1) 
     appExcel.Visible = True 
    
    End Sub


    Ne pas oublier de cocher la librairie excel dans Projet/Références/Microsoft Excel...

    @+

    Développeur VB6, VBS, VBA, VB.NET, C#, HTML, PHP, JAVASCRIPT, SQL.
    0
    1. derch
       
      merci bcp ,mais le petit problème c'est que en excel 2007 il faut ajouter un x
      par exemple/open("D:\monprojet\classeur1.xlsx")
      monprojet c'est lefichier ou se trouve classeur1

      JE VOUS PROPOSE UN AUTRE CODE QUE JE VOIX UN PEUT PLUS COURT
      (General)
      Dim xlTmp As Excel.Application
      Private Sub Command1_Click()

      Set xlTmp = Excel.Application
      xlTmp.Workbooks.Open ("d:\nom du fichier contenant le classeur\Classeur1.xlsx")
      xlTmp.Visible = True
      End Sub
      0