Msflexgrid vers Excel

cs_tolt Messages postés 269 Date d'inscription mardi 17 décembre 2002 Statut Membre Dernière intervention 4 avril 2019 - 6 avril 2008 à 16:53
cs_tolt Messages postés 269 Date d'inscription mardi 17 décembre 2002 Statut Membre Dernière intervention 4 avril 2019 - 6 avril 2008 à 18:27
Bonjour,

Qui connait la solution pour à partir d'un programme VB6 colorier une cellule Excel comme le montre mon exemple ci-dessous avec une couleure personnalisée venant d'un MSFLEXGRID ?

    With Selection.Interior
        .ColorIndex = 16744703
        .Pattern = 1
        .PatternColorIndex = -4105
    End With

Sinon si quelqu'un à déjà fait une fonction de transfert d'un MSFLEXGRID avec couleure etc...vers Excel
je suis preneur.

MERCI D'AVANCE !!!

tolt

2 réponses

cs_DARKSIDIOUS Messages postés 15814 Date d'inscription jeudi 8 août 2002 Statut Membre Dernière intervention 4 mars 2013 130
6 avril 2008 à 18:00
Salut,

Un petit bout de code que je me sers dans ce but, à toi d'adapter à ton cas :

On Error GoTo Erreur

Dim iFor1 As Integer
Dim iFor2 As Integer
Dim sText As String
Dim oExcel As Object
Dim iIndexLigne As Integer
Dim iIndexColonne As Integer

    Set oExcel = CreateObject("excel.application")
    If oExcel Is Nothing Then

        Call MsgBox("Impossible d'exporter vers le format excel : Excel n'a pas été trouvé sur la machine.", vbOKOnly + vbExclamation, "Exportation impossible")

    End If
    Let Screen.MousePointer = vbHourglass

    oExcel.Visible = True
    oExcel.Workbooks.Add.Activate
    DoEvents
   
    With oExcel.Worksheets("Feuil1")
   
        Let iIndexColonne = 1
        Let iIndexLigne = 1
       
        For iFor1 = 0 To Me.flxGrid.Cols
       
            Let .Cells(0, iFor1 + 1) = Me.flxGrid.TextMatrix(-1, iFor1)
       
        Next iFor1

        For iFor1 = 0 To Me.flxGrid.Rows
       
            For iFor2 = 0 To Me.flxGrid.Cols
           
                Let .Cells(iFor1 + 1, iFor2 + 1) = Me.flxGrid.TextMatrix(iFor1, iFor2)

            Next iFor2
            DoEvents
            Let .Range("A1:" & Chr(65 + Me.flxGrid.Cols - 1) & iFor1).Borders.LineStyle = xlContinuous
            Let .Range("A1:" & Chr(65 + Me.flxGrid.Cols - 1) & iFor1).Borders.Weight = xlMedium

        Next iFor1
       
        Let iIndexColonne = 1
        Let iIndexLigne = iIndexLigne + 1

______________________________________
DarK Sidious
0
cs_tolt Messages postés 269 Date d'inscription mardi 17 décembre 2002 Statut Membre Dernière intervention 4 avril 2019
6 avril 2008 à 18:27
Salut DARKSIDIOUS

J'ai trouvé la solution, voici le code
Merci en tout cas et bonne soirée.

    With xls.Selection.Interior
        .Color = WflexGrid.CellBackColor
        .Pattern = 1
        .PatternColorIndex = -4105
    End With

   Il faut utiliser Color et Colorindex !!!

For X = 0 To WflexGrid.Cols - 1
    xls.ActiveSheet.Columns(X + 1).EntireColumn.AutoFit
Next X

tolt
0
Rejoignez-nous