Bonjour à tous, voici mes début en programmation et mes 1ers Bug. Je fais donc appel à vous pour espérer un peu d'aide.
Quand je lance la première fois cette macro :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| Private Sub Image_Ok_Click()
Dim appExcel As Excel.Application 'Application Excel
Dim wbExcel As Excel.Workbook 'Classeur Excel
Dim wsExcel As Excel.Worksheet 'Feuille Excel
Dim var_datedebut As Date
Dim var_datefin As Date
Dim var_jourlabo As Byte
Dim var_numessai As String
'Ouverture de l'application
Set appExcel = CreateObject("Excel.Application")
'Ouverture d'un fichier Excel
Set wbExcel = appExcel.Workbooks.Open("\\Bdcnantes2002\BASEDOC\Processus interne\Bureau d'Etude\Essais initiaux\Logiciel - GHEL\Planning GHEL.xls")
'wsExcel correspond à la première feuille du fichier
Set wsExcel = wbExcel.Worksheets(1)
appExcel.Visible = True 'Rendre le doc visible
'Récupération du classeur par défaut
Set wbExcel = appExcel.ActiveWorkbook
'Récupération de la feuille par défaut
Set wsExcel = wbExcel.ActiveSheet
var_jourlabo = Texte_JourneeEstimee.Value
var_datefin = DateEssaiPlannifiee.Value
var_datedebut = DateEssaiPlannifiee - Texte_JourneeEstimee.Value
var_numessai = Texte_NumEssai.Value
For i = 7 To 100
If ActiveSheet.Range("A" & i).Value = "" Then GoTo lignefin Else
Next i
lignefin:
ActiveSheet.Range("A" & i).Activate
ActiveSheet.Range("A" & i).Value = var_numessai
ActiveSheet.Range("B" & i).Activate
ActiveSheet.Range("B" & i).Value = var_datedebut
ActiveSheet.Range("C" & i).Activate
ActiveSheet.Range("C" & i).Value = var_datefin
ActiveWorkbook.Save
wbExcel.Close 'Fermeture du classeur Excel
appExcel.Quit 'Fermeture de l'application Excel
'Désallocation mémoire
Set wsExcel = Nothing
Set wbExcel = Nothing
Set appExcel = Nothing
'KillProcess "Excel.exe"
End Sub |
Je n'ai pas de problème d'éxecution, cependant si je veux relancer de nouveau la commande, j'ai une erreur :
[Erreur d'exécution '91'] Variable objet ou variable bloc With nondéfi à la ligne :
If ActiveSheet.Range("A" & i).Value = "" Then GoTo lignefin Else
...pouvez-vous m'aider ?
Merci
Windows XP / Access 2007
Partager