Bonjour à tous,
J'ai créé une macro avec Excel 2007 et je voudrais intégrer le code généré dans une application VB.Net 2005, juste pour faire le design de ma feuille Excel. Mais je ne m'en sort pas du tout. Voici le code géné avec les quelques modification que j'ai apportée. Donnez moi un coup de point s'il vous plait.
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162 Sub Mise_En_Forme_Excel() ' ' Macro1 Macro ' Dim monda As New OleDb.OleDbDataAdapter Dim App_Excel As Microsoft.Office.Interop.Excel.Application Dim Classeur As Microsoft.Office.Interop.Excel.Workbook Dim Feuille As Microsoft.Office.Interop.Excel.Worksheet 'Columns(1).EntireColumn.AutoFit() Feuille.Columns(1).EntireColumn.AutoFit() Feuille.Columns(2).EntireColumn.AutoFit() Feuille.Columns(3).EntireColumn.AutoFit() Feuille.Columns(4).EntireColumn.AutoFit() Feuille.Columns(5).EntireColumn.AutoFit() Feuille.Range("A4:E").Select() With Feuille.Range("A4:E4").Font .Bold = True .Name = "Calibri" .Size = 12 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = Microsoft.Office.Interop.Excel.XlUnderlineStyle.xlUnderlineStyleNone 'xlUnderlineStyleNone .ThemeColor = Microsoft.Office.Interop.Excel.XlThemeColor.xlThemeColorLight1 'xlThemeColorLight1 .TintAndShade = 0 .ThemeFont = Microsoft.Office.Interop.Excel.XlThemeFont.xlThemeFontMinor 'xlThemeFontMinor End With Feuille.Range("A4:E4").Borders(XlBordersIndex.xlDiagonalDown).LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlLineStyleNone '(xlDiagonalDown).LineStyle = xlNone Feuille.Range("A4:E4").Borders(XlBordersIndex.xlDiagonalUp).LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlLineStyleNone '(xlDiagonalUp).LineStyle = xlNone With Feuille.Range("A4:E4").Borders(XlBordersIndex.xlEdgeLeft) '(xlEdgeLeft) .LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous 'xlContinuous .ColorIndex = 0 .TintAndShade = 0 '.Weight = xlThin End With With Feuille.Range("A4:E4").Borders(XlBordersIndex.xlEdgeTop) '(xlEdgeTop) .LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous 'xlContinuous .ColorIndex = 0 .TintAndShade = 0 '.Weight = xlThin End With With Feuille.Range("A4:E4").BordersBorders(XlBordersIndex.xlEdgeBottom) '(xlEdgeBottom) .LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous 'xlContinuous .ColorIndex = 0 .TintAndShade = 0 '.Weight = xlThin End With With Feuille.Range("A4:E4").Borders(XlBordersIndex.xlEdgeRight) '(xlEdgeRight) .LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous 'xlContinuous .ColorIndex = 0 .TintAndShade = 0 '.Weight = xlThin End With With Feuille.Range("A4:E4").Borders(XlBordersIndex.xlInsideVertical) .LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous 'xlContinuous .ColorIndex = 0 .TintAndShade = 0 '.Weight = xlThin End With With Feuille.Range("A4:E4").Borders(XlBordersIndex.xlInsideHorizontal) .LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous 'xlContinuous .ColorIndex = 0 .TintAndShade = 0 '.Weight = xlThin End With Feuille.Range("A4:E4").Borders(XlBordersIndex.xlDiagonalDown).LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlLineStyleNone 'xlNone Feuille.Range("A4:E4").Borders(XlBordersIndex.xlDiagonalUp).LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlLineStyleNone 'xlNone With Feuille.Range("A4:E4").Borders(XlBordersIndex.xlEdgeLeft) '(xlEdgeLeft) .LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous 'xlContinuous .ColorIndex = 0 .TintAndShade = 0 '.Weight = xlThin End With With Feuille.Range("A4:E4").Borders(XlBordersIndex.xlEdgeTop) .LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous 'xlContinuous .ColorIndex = 0 .TintAndShade = 0 ' .Weight = xlThin End With With Feuille.Range("A4:E4").Borders(XlBordersIndex.xlEdgeBottom) .LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlDouble 'xlDouble .ColorIndex = 0 .TintAndShade = 0 '.Weight = xlThick End With With Feuille.Range("A4:E4").Borders(XlBordersIndex.xlEdgeRight) .LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous 'xlContinuous .ColorIndex = 0 .TintAndShade = 0 '.Weight = xlThin End With With Feuille.Range("A4:E4").Borders(XlBordersIndex.xlInsideVertical) .LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous 'xlContinuous .ColorIndex = 0 .TintAndShade = 0 '.Weight = xlThin End With Feuille.Range("A4:E4").Borders(XlBordersIndex.xlInsideHorizontal).LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlLineStyleNone 'xlNone Feuille.Range("A5:E1093").Select() Feuille.Range("A5:E1093").Borders(XlBordersIndex.xlDiagonalDown).LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlLineStyleNone 'xlNone Feuille.Range("A5:E1093").Borders(XlBordersIndex.xlDiagonalUp).LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlLineStyleNone 'xlNone With Feuille.Range("A5:E1093").Borders(XlBordersIndex.xlEdgeLeft) .LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous 'xlContinuous .ColorIndex = 0 .TintAndShade = 0 '.Weight = xlThin End With With Feuille.Range("A5:E1093").Borders(XlBordersIndex.xlEdgeTop) .LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous 'xlContinuous .ColorIndex = 0 .TintAndShade = 0 '.Weight = xlThin End With With Feuille.Range("A5:E1093").Borders(XlBordersIndex.xlEdgeBottom) .LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous 'xlContinuous .ColorIndex = 0 .TintAndShade = 0 '.Weight = xlThin End With With Feuille.Range("A5:E1093").Borders(XlBordersIndex.xlEdgeRight) .LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous 'xlContinuous .ColorIndex = 0 .TintAndShade = 0 '.Weight = xlThin End With With Feuille.Range("A5:E1093").Borders(XlBordersIndex.xlInsideVertical) .LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous 'xlContinuous .ColorIndex = 0 .TintAndShade = 0 '.Weight = xlThin End With With Feuille.Range("A5:E1093").Borders(XlBordersIndex.xlInsideHorizontal) .LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous 'xlContinuous .ColorIndex = 0 .TintAndShade = 0 '.Weight = xlThin End With Feuille.Range("A4:E4").Select() With Feuille.Range("A4:E4").Interior .Pattern = Microsoft.Office.Interop.Excel.XlPattern.xlPatternSolid 'xlSolid .PatternColorIndex = Microsoft.Office.Interop.Excel.XlPattern.xlPatternAutomatic 'xlAutomatic .Color = 5287936 .TintAndShade = 0 .PatternTintAndShade = 0 End With With Feuille.Range("A4:E4").Font .Color = -3394816 .TintAndShade = 0 End With Feuille("Feuil1").Select() Sheets("Feuil1").Name = "Liste generale" Range("B2").Select() Sheets("Liste generale").Select() End Sub
Partager