Bonjour,
Je débute les macros sur calc, et j'essaie de créer une macro permettant de copier-coller en valeur des données actualisées vers une base. La macro semble bien fonctionner : lorsque je clique sur le bouton créé, les données souhaitées se collent sur la base à l'endroit souhaité, sauf qu'elles ne sont pas actualisées : il s'agit des données copiées initialement lors de l'enregistrement de la macro qui se collent et non les nouvelles données calculées.
Je vous mets ci-dessous la macro :

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
99
100
101
102
103
104
105
REM  *****  BASIC  *****
 
 
sub lul
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
 
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Calculate", "", 0, Array())
 
rem ----------------------------------------------------------------------
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "ToPoint"
args2(0).Value = "$A$65"
 
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args2())
 
rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "By"
args3(0).Value = 1
 
dispatcher.executeDispatch(document, ".uno:GoRightToEndOfDataSel", "", 0, args3())
 
rem ----------------------------------------------------------------------
dim args4(0) as new com.sun.star.beans.PropertyValue
args4(0).Name = "By"
args4(0).Value = 1
 
dispatcher.executeDispatch(document, ".uno:GoDownToEndOfDataSel", "", 0, args4())
 
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())
 
rem ----------------------------------------------------------------------
dim args6(0) as new com.sun.star.beans.PropertyValue
args6(0).Name = "Nr"
args6(0).Value = 2
 
dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args6())
 
rem ----------------------------------------------------------------------
dim args7(0) as new com.sun.star.beans.PropertyValue
args7(0).Name = "ToPoint"
args7(0).Value = "$A$1"
 
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args7())
 
rem ----------------------------------------------------------------------
dim args8(1) as new com.sun.star.beans.PropertyValue
args8(0).Name = "By"
args8(0).Value = 1
args8(1).Name = "Sel"
args8(1).Value = false
 
dispatcher.executeDispatch(document, ".uno:GoDownToEndOfData", "", 0, args8())
 
rem ----------------------------------------------------------------------
dim args9(1) as new com.sun.star.beans.PropertyValue
args9(0).Name = "By"
args9(0).Value = 1
args9(1).Name = "Sel"
args9(1).Value = false
 
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args9())
 
rem ----------------------------------------------------------------------
dim args10(5) as new com.sun.star.beans.PropertyValue
args10(0).Name = "Flags"
args10(0).Value = "SVD"
args10(1).Name = "FormulaCommand"
args10(1).Value = 0
args10(2).Name = "SkipEmptyCells"
args10(2).Value = false
args10(3).Name = "Transpose"
args10(3).Value = false
args10(4).Name = "AsLink"
args10(4).Value = false
args10(5).Name = "MoveMode"
args10(5).Value = 4
 
dispatcher.executeDispatch(document, ".uno:InsertContents", "", 0, args10())
 
rem ----------------------------------------------------------------------
dim args11(0) as new com.sun.star.beans.PropertyValue
args11(0).Name = "Nr"
args11(0).Value = 1
 
dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args11())
 
rem ----------------------------------------------------------------------
dim args12(0) as new com.sun.star.beans.PropertyValue
args12(0).Name = "ToPoint"
args12(0).Value = "$G$6"
 
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args12())
 
 
end sub
Merci beaucoup pour votre aide.
Bien cordialement.