Bonsoir

J'ai un bouton sur une userform (voir code ci-dessous) pour créer des formes libres avec des paramètres définis sur une page excel.

Ce code fonctionne très bien sur Excel 2003. Par contre sur Excel 2007, cette macro se lance mais impossible de dessiner.

Existe-t-il un moyen de corriger ce problème?

D'avance merci.

Regor




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
Private Sub CommandButton2_Click()
 
 
ActiveSheet.Shapes.AddLine(234.75, 107.25, 403.5, 107.25).Select
    Selection.ShapeRange.Line.ForeColor.SchemeColor = 12
    Selection.ShapeRange.Line.Visible = msoTrue
    Selection.ShapeRange.Line.ForeColor.SchemeColor = 10
    Selection.ShapeRange.Line.Visible = msoTrue
    Selection.ShapeRange.Line.Weight = 6#
    Selection.ShapeRange.Line.Visible = msoTrue
    Selection.ShapeRange.Line.Style = msoLineSingle
    Selection.ShapeRange.Line.Visible = msoTrue
    Selection.ShapeRange.Line.Style = msoLineThinThick
    Selection.ShapeRange.Line.Weight = 4.5
    Selection.ShapeRange.SetShapesDefaultProperties
    Selection.Delete
 
Dim cmd_bar As CommandBar, cmd_control As CommandBarButton
 
Set cmd_bar = Application.CommandBars("Lines")
 
For Each cmd_control In cmd_bar.Controls
 
    If cmd_control.ID = 200 Then
cmd_control.Execute
 
 
Exit For
 
End If
 
Next
 
 
End Sub