Hello tout le mode

J'essaye de realiser un script qui permet de transferer une variable sur une ligne et colonne d'Excel
Le probleme est que je ne voudrais pas que la valeur de la ligne dans le script soit fixe

Lorsque je met une variable dans "excel.Cells" mon script ne marche plus...
Exemple: excel.Cells(compteurtrans, 3).Value = ScreenItems("Temps_utilisation_moteur_journée").OutputValue

ici "compteurtrans" permet de choisir la ligne non?

Mais le script ne marche marche pas avec la variable... Est ce que j'utilise la bonne methode?



Merci





Mon script



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
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
Sub Click(Byval Item)                        
Dim g_excelfilename
Dim excel
'rajouté

Dim projectname,projectpath,group
Dim compteurtrans

Set compteurtrans = HMIRuntime.Tags("NbDeTransfert")

'Aktuellen Projektnamen und Pfad ermitteln - Get actual projectname and projectpath

projectname = HMIRuntime.ActiveProject.Name
projectpath = HMIRuntime.ActiveProject.Path

HMIRuntime.Tags("ProjectName").Write projectname
HMIRuntime.Tags("ProjectPath").Write projectpath

'rajouté


g_excelfilename = HMIRuntime.Tags("ProjectPath").Read & "\Excel1.xls"
'MsgBox g_excelfilename
Set excel = CreateObject("Excel.Application")
excel.Visible = True
excel.Workbooks.Open g_excelfilename
excel.Cells(compteurtrans, 3).Value = ScreenItems("Temps_utilisation_moteur_journée").OutputValue
excel.Cells(4, 4).Value = ScreenItems("Compteur_Dep_journée").OutputValue
excel.Cells(4, 5).Value = ScreenItems("Compteur_Def_journée").OutputValue
excel.ActiveWorkbook.Save
MsgBox ("Voulez vous transferez les valeurs moyennes dans WinCC")
ScreenItems("V6_ExcelRead_1").OutputValue = excel.Cells(4, 11).Value
ScreenItems("V6_ExcelRead_2").OutputValue = excel.Cells(5, 11).Value
ScreenItems("V6_ExcelRead_3").OutputValue = excel.Cells(6, 11).Value
excel.ActiveWorkbook.Save
excel.Workbooks.Close
excel.Quit
Set excel = Nothing







End Sub