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