| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 
 |  //Pour ne voir que les fichiers cvs et xls
  OpenDialog1->Filter = "Fichiers excel (*.XLS) (*.xls)|*.xls|Fichiers CSV (*.CSV) (*.csv)|*.csv"; //|Tous les fichiers (*.*)|*.*");
  // si clic sur ouvrir
  if (OpenDialog1->Execute()){
    ///////////////// code ///////////////////
    Variant vMSExcel , vNotUsed, vSeparator, vXLWorkbooks, vXLWorkbook;
    String vFileName, chemin_macro;
    AnsiString Extension = ExtractFileExt(fichier_ouvrir).LowerCase();
    //  ShowMessage(Extension);
    // si c'est un fichier csv ou xls on traite sinon c'est un repertoire et on ne fait rien
    if (Extension==".csv" || Extension==".xls" ){
      // on ouvre une instance excel
      vMSExcel = Variant::CreateObject("Excel.Application");
      //vMSExcel.OlePropertySet("Visible", false); // on cache excel
      vMSExcel.OlePropertySet("DisplayFullScreen", true);
      vMSExcel.OlePropertySet("DisplayAlerts", false);
      // on donne a vFileName le nom du fichier a ouvrir
      vFileName = fichier_ouvrir;
      vXLWorkbooks = vMSExcel.OlePropertyGet("Workbooks");
      vXLWorkbook = vXLWorkbooks.OleFunction("Open", vFileName.c_str());//, vNotUsed, vNotUsed,vSeparator);
      // access a la feuille
      Variant vWorksheet;
      Variant vWsPos = 1;  // position de la feuille a utiliser | 
Partager