Il me faut une solution,please !!!

cs_Florian29 Messages postés 52 Date d'inscription samedi 8 juin 2002 Statut Membre Dernière intervention 12 avril 2006 - 21 juin 2003 à 14:08
cs_Florian29 Messages postés 52 Date d'inscription samedi 8 juin 2002 Statut Membre Dernière intervention 12 avril 2006 - 22 juin 2003 à 19:05
Salut !
J'ai deux problèmes qu'il faut que je résolve ce week-end:
1) Comment il faut faire pour choisir les couleurs des courbes d'un MSCHART depuis le code VB ??

2) Comment mettre une couleur de fond sur une cellule précise d'un fichier excel depuis VB? J'arrive à remplir tout ce que je veux dans le fichier excel mais pas à choisir de couleur..

Ca paraît pas important comme ça, mais un prof à qui je dois rendre un projet me prend la tête avec ses couleurs...Si quelqun peut m'aider, ce serait super sympa!
Merci!

2 réponses

nhervagault Messages postés 6063 Date d'inscription dimanche 13 avril 2003 Statut Membre Dernière intervention 15 juillet 2011 37
21 juin 2003 à 15:22
Pour formater mschart

Private Sub cmdFormat_Click()
' First, change the chart type to a 3D chart to
' see all the parts of the plot.
MSChart1.chartType = VtChChartType2dLine


' Color the backdrop light blue using
' the Plot object.
With MSChart1.Plot.Backdrop
' No color will appear unless you set the style
' property to VtFillStyleBrush.
.Fill.Style = VtFillStyleBrush
'.Fill.Brush.FillColor.Set 100, 255, 200
' Add a border.
.Frame.Style = VtFrameStyleThickInner
' Set style to show a shadow.
.Shadow.Style = VtShadowStyleDrop
End With
'
' ' Color the wall of the plot yellow.
' With MSChart1.Plot
' ' Set the style to solid.
' .Wall.Brush.Style = VtBrushStyleSolid
' ' Set the color to yellow.
' .Wall.Brush.FillColor.Set 255, 255, 0
' End With

With MSChart1.Plot ' Color the plot base blue.
.PlotBase.BaseHeight = 200
.PlotBase.Brush.Style = VtBrushStyleSolid
.PlotBase.Brush.FillColor.Set 0, 0, 255
End With
End Sub

Color de cellule excel depuis vb

Ce code dois marcher (pas tester)
Option Explicit

Private m_objExcel As Excel.Application
Private m_objExcelWkSht As Excel.Worksheet

Sub Main()
Dim Color As Long

Set m_objExcel = New Excel.Application
m_objExcel.Visible = True
m_objExcel.Workbooks.Add
Set m_objExcelWkSht = m_objExcel.ActiveWorkbook.Sheets(1)
m_objExcelWkSht.Range("A1").Select
m_objExcel.ActiveCell.Formula = "Color"
m_objExcel.ActiveCell.Offset(0, 1).Formula = "Color Index
Number "
m_objExcel.ActiveCell.Offset(1, 0).Activate

For Color = 1 To 56
With m_objExcel.ActiveCell.Interior
.ColorIndex = Color
.Pattern = xlPatternSolid
.PatternColorIndex = xlColorIndexAutomatic
End With
ActiveCell.Offset(1, 0).Activate
Next Color

End Sub
0
cs_Florian29 Messages postés 52 Date d'inscription samedi 8 juin 2002 Statut Membre Dernière intervention 12 avril 2006
22 juin 2003 à 19:05
Merci beaucoup pr ton aide, je vais essayer, ms ca me parait pas mal !!
A +
0
Rejoignez-nous