Bonjour,

D'abord voici mon code :

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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
 
Option Explicit
 
'
' Variables
'
 
Dim objExcel    		' Excel
Dim objWorkbook 		' Le classeur
Dim objWorksheet		' La feuille
'Dim objWorkbook_Inter 	' Le classeur Backlog_Inter.xls
Dim Path        		' Chemin de lancement du script
Dim objFSO
Dim strCurDate  		' Date du jour
Dim XLDest, XLOrg		' Nom des classeurs
Dim Datation
 
Set objExcel = CreateObject("Excel.Application")
Set objFSO = CreateObject("Scripting.FileSystemObject")
objExcel.Visible = true
Path = Replace(WScript.ScriptFullName, WScript.ScriptName, "")
WScript.Echo "Nous sommes le " & Now()
strCurDate = Mid(Now(),7,4) & Mid(Now(),4,2) & Left(Now(),2) 'Date du jour au format AAAAMMJJ
XLDest = Path & "Backlog_" & strCurDate & ".xls"
XLOrg = Path & "Backlog_Inter.xls"
'WScript.Echo "Calculation : " & objExcel.Calculation
'objExcel.Calculation = xlManual
'WScript.Echo "Calculation : " & objExcel.Calculation
'
' Copier le fichier sous le nom Backlog_aaaammjj
'
If objFSO.FileExists(Path & "2013Backlog5fDC35fAdmin5fGroupe5f22dTB.xls") And Not objFSO.FileExists(XLDest) Then
	objFSO.CopyFile Path & "2013Backlog5fDC35fAdmin5fGroupe5f22dTB.xls", XLDest 
	Set objFSO = Nothing
	WScript.Echo "Le fichier " & Path & "2013Backlog5fDC35fAdmin5fGroupe5f22dTB.xls a été copié en " & XLDest & "."
End If
 
Set objWorkbook = objExcel.Workbooks.Open (XLDest)
'Set objWorkbook_Inter = objExcel.Workbooks.Open (XLOrg)
 
'
' Ajouter une feuille à la fin du classeur
'
 
Set objWorksheet = objExcel.Worksheets.Add(,objExcel.Worksheets(objExcel.Worksheets.Count))
 
'
' Copie des colonnes
'
 
' ID incident
Set objWorksheet = objExcel.Worksheets(1)
objWorksheet.Range("A1","A65536").Copy
Set objWorksheet = objExcel.Worksheets(2)
objWorksheet.Paste objWorksheet.Range("A1","A65536")
 
' Etat
Set objWorksheet = objExcel.Worksheets(1)
objWorksheet.Range("G1","G65536").Copy
Set objWorksheet = objExcel.Worksheets(2)
objWorksheet.Paste objWorksheet.Range("B1","B65536")
 
' Intervenant
Set objWorksheet = objExcel.Worksheets(1)
objWorksheet.Range("I1","I65536").Copy
Set objWorksheet = objExcel.Worksheets(2)
objWorksheet.Paste objWorksheet.Range("C1","C65536")
 
' Date de création
Set objWorksheet = objExcel.Worksheets(1)
objWorksheet.Range("P1","P65536").Copy
Set objWorksheet = objExcel.Worksheets(2)
objWorksheet.Paste objWorksheet.Range("D1","D65536")
 
' Calcul date
Datation = objWorksheet.Cells(4,2).Value
'Datation = objWorksheet.WorksheetFunction.Mid(Datation, 1, 10) '= "=STXT(D2;1;10)"
'objWorksheet.Cells("E2").FormulaLocal = "=STXT(D2,1,10)" '"=STXT(D2;1;10)"
objWorksheet.Cells(2,5).Formula = "=STXT(" & objWorksheet.Cells(2,4).Address & ",1,10)"
'objWorksheet.Cells(5,2).Value = Datation
 
objWorksheet.EnableCalculation = False
objWorksheet.EnableCalculation = True
 
'
' Sauvegarde du classeur
'
objWorkbook.Save()
 
 
'
' Fin de traitement
'
 
objExcel.Quit
Set objWorkbook = Nothing
'Set objWorkbook_Inter = Nothing
Set objExcel = Nothing
Je souhaiterais insérer une formule dans une cellule (voir un range) :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
objWorksheet.Cells(2,5).Formula = "=STXT(" & objWorksheet.Cells(2,4).Address & ",1,10)"
Malheureusement, si la formule apparaît bien dans la cellule quand j'ouvre le fichier Excel. Il y a aussi #NOM qui apparaît à la place du résultat.

Par contre quand j'édite la formule et que je fais un simple retour chariot. Cette fois le résultat apparaît correctement.

Comment peut-on automatiser la prise en compte de la formule ?

A Bientôt

Karon.