Consulting

Results 1 to 11 of 11

Thread: Help! please! CHANGING SHAPE COLORS IN POWERPOINT WITH A DATABASE

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,446
    Location
    Here you are my friend, you will need to set the database path variable to your file. I have just used the colours red, green and blue. Again, set the RGB values to your preference.

    I assume that map is part of Mexico, whereabouts? I was due to be holidaying in Mexico on 14th of this month, near Leon, but that has been knocked on the head.

    Const DB_PATH As String = "C:\Users\Bob\Documents\Projects\_8 Community\Forums\VBAExpress\VBAX 67286 - Changing Shapes Colour in Powerpoint\covid19.accdb"
    
    Public Function SetColours()
    Dim data As Variant
    Dim shapecolour As Variant
    Dim i As Long
    
        data = GetData
            
        With ActivePresentation.Slides(1)
        
            For i = LBound(data, 2) To UBound(data, 2)
            
                Select Case data(1, i)
                
                    Case "A":   shapecolour = RGB(255, 0, 0)
                    Case "B":   shapecolour = RGB(0, 255, 0)
                    Case "C":   shapecolour = RGB(0, 0, 255)
                End Select
    
                .Shapes(data(2, i)).Fill.ForeColor.RGB = shapecolour
            Next i
        End With
    End Function
    
    
    Private Function GetData() As Variant
    Dim conn As Object
    Dim RS As Object
    Dim intColIndex As Integer
    Dim DBFullName As String
    
        Set conn = CreateObject("ADODB.Connection")
        With conn
        
            .Provider = "Microsoft.ACE.OLEDB.12.0"
            .Open DB_PATH
        End With
        Set RS = CreateObject("ADODB.Recordset")
        RS.Open "SELECT * FROM [catmun]", conn, , , 1 'adCmdText
        
        GetData = RS.GetRows
    
        RS.Close: Set RS = Nothing
        conn.Close: Set conn = Nothing
    End Function
    Last edited by Bob Phillips; 05-03-2020 at 04:35 AM.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •