cs_Cavo
Messages postés9Date d'inscriptionlundi 1 juillet 2002StatutMembreDernière intervention20 septembre 2002
-
1 juil. 2002 à 11:07
cs_Cavo
Messages postés9Date d'inscriptionlundi 1 juillet 2002StatutMembreDernière intervention20 septembre 2002
-
1 juil. 2002 à 13:23
J'aimerais pouvoir modifier la couleur des cellules d'une feuille excel: voici mes sources
Dim Ex As New excel.Application
'Initialisation de l'objet
Set Ex = New excel.Application
'Ouverture du modèle Excel (modèle.xlt)
Ex.Workbooks.Add Modèle
'Remplissage des cellules fixes
Ex.Cells(1, 1) = "Date de la demande : " & Lbl_date_demande.Caption & "" 'Met une valeur dans la cellule B2
Ex.Cells(2, 1) = "Nom et Prénom du demandeur : " & Cbo_demandeur.text & " "
Ex.Cells(3, 1) = "Service : " & Demandeur_N(Cbo_demandeur.ListIndex).service & ""
Ex.Cells(4, 1) = "C.I. : " & Demandeur_N(Cbo_demandeur.ListIndex).CI & ""
Ex.Cells(5, 1) = "Besoin en vacataire du " & Lbl_début & " Au " & Lbl_fin & ""
'Remplissage du tableau excel
nbre = MSHFlexGrid1.Rows - 1
MSHFlexGrid1.SelectionMode = flexSelectionFree
Z = 2
For X = 1 To nbre
MSHFlexGrid1.Row = X
MSHFlexGrid1.RowSel = X
Ex.Cells((X + 7), (1)) = MSHFlexGrid1.TextMatrix(X, 0)
Ex.Cells((X + 7), (2)) = MSHFlexGrid1.TextMatrix(X, 1)
For Y = 2 To 8
MSHFlexGrid1.Col = Y
MSHFlexGrid1.ColSel = Y
If Y > 2 Then
Ex.Cells((X + 7), ((Y * 2) - 1)) = MSHFlexGrid1.TextMatrix(X, Y)
Else
Ex.Cells((X + 7), (Y + 1)) = MSHFlexGrid1.TextMatrix(X, Y)
End If
Next
Next
'Mise en couleur des cellules
'Affichage de l'objet excel :
Ex.Visible = True
'Impression du fichier excel :
'Ex.ActiveSheet.PrintOut [1]
'Fermeture de l'objet excel :
On Error Resume Next
Ex.Workbooks.Close
cs_Cavo
Messages postés9Date d'inscriptionlundi 1 juillet 2002StatutMembreDernière intervention20 septembre 2002 1 juil. 2002 à 11:29
-------------------------------
Réponse au message :
-------------------------------
J'aimerais pouvoir modifier la couleur des cellules d'une feuille excel: voici mes sources
Dim Ex As New excel.Application
'Initialisation de l'objet
Set Ex = New excel.Application
'Ouverture du modèle Excel (modèle.xlt)
Ex.Workbooks.Add Modèle
'Remplissage des cellules fixes
Ex.Cells(1, 1) = "Date de la demande : " & Lbl_date_demande.Caption & "" 'Met une valeur dans la cellule B2
Ex.Cells(2, 1) = "Nom et Prénom du demandeur : " & Cbo_demandeur.text & " "
Ex.Cells(3, 1) = "Service : " & Demandeur_N(Cbo_demandeur.ListIndex).service & ""
Ex.Cells(4, 1) = "C.I. : " & Demandeur_N(Cbo_demandeur.ListIndex).CI & ""
Ex.Cells(5, 1) = "Besoin en vacataire du " & Lbl_début & " Au " & Lbl_fin & ""
'Remplissage du tableau excel
nbre = MSHFlexGrid1.Rows - 1
MSHFlexGrid1.SelectionMode = flexSelectionFree
Z = 2
For X = 1 To nbre
MSHFlexGrid1.Row = X
MSHFlexGrid1.RowSel = X
Ex.Cells((X + 7), (1)) = MSHFlexGrid1.TextMatrix(X, 0)
Ex.Cells((X + 7), (2)) = MSHFlexGrid1.TextMatrix(X, 1)
For Y = 2 To 8
MSHFlexGrid1.Col = Y
MSHFlexGrid1.ColSel = Y
If Y > 2 Then
Ex.Cells((X + 7), ((Y * 2) - 1)) = MSHFlexGrid1.TextMatrix(X, Y)
Else
Ex.Cells((X + 7), (Y + 1)) = MSHFlexGrid1.TextMatrix(X, Y)
End If
Next
Next
'Mise en couleur des cellules
'Affichage de l'objet excel :
Ex.Visible = True
'Impression du fichier excel :
'Ex.ActiveSheet.PrintOut [1]
'Fermeture de l'objet excel :
On Error Resume Next
Ex.Workbooks.Close