Bonjour,
Je tourne en rond pour un problème tout simple... A partir d'un fichier excel existant je veux ouvrir et je lire un autre fichier. Jusque là, pas de problème, j'arrive à lancer une application excel et ouvrir mon fichier.
Maintenant je voudrais tester une à une les entêtes d'un tableau contenu dans ce fichier. Par exemple si une entête "T" est dans le UsedRange, je considère que la colonne température est présente et je mets la valeur booléenne correspondante à TRUE.
Je voulais donc faire ceci, mais ça ne marche pas -> ActiveCell.Value est soit vide soit incohérent...!
-------------------------------------------------------------------------
'Open the file in a temporary excel application
'----------------------------------------------
Set AppSource = CreateObject("Excel.Application")
Set wbSource = AppSource.Workbooks.Open(strFile, ReadOnly:=True)
AppSource.Visible = True
'Input File test
'---------------
Dim strLocation As String
Dim intCol As Integer
strLocation = wbSource.Worksheets(1).Cells(1, 1).Value
If wbSource.Worksheets(1).Cells(1, 1) <> Empty Then boolLocation = True
If wbSource.Worksheets(1).Cells(2, 1) <> Empty Then boolLatitude = True
' C'est ici que j'ai un problème:
wbSource.Worksheets(1).Cells(4, 1).Active
For i = 1 To wbSource.Worksheets(1).UsedRange.Columns.Count
If ActiveCell.Value = "<G_Bh>" Then boolBeamRadiation = True
If ActiveCell.Value = "<G_Dh>" Then boolDiffuseRadiation = True
If ActiveCell.Value = "<G_Dh>" Then boolGlobalRadiation = True
If ActiveCell.Value = " dy" Or ActiveCell.Value = "dy" Then boolDay = True
If ActiveCell.Value = " h" Or ActiveCell.Value = "h" Then boolHour = True
If ActiveCell.Value = " FF" Or ActiveCell.Value = "FF" Then boolWindSpeed = True
ActiveCell.Offset(0, 1).Activate
Next i
--------------------------------------------------------------------------
Si quelqu'un peu me dépanner... Je le remercie d'avance!!
Partager