Changing text colour of fields from recordset in MS Word RRS feed

  • Question

  • Hi there,

    I am trying to pull some data from a MS Access database and populate it in a MS Word document. I would like to set some of the fields with diffrent font colours then others. So far, I can change the font size and color of the whole document but can not change it for a specific field. 

    I would appreciate any help with this matter. A sample of the code I am working with is listed below:

    Private Sub Chart()
        Dim dbChar2 As DAO.Database
        Dim rdServices As Recordset
        Dim intRecords As Integer

    Set dbChar2 = OpenDatabase _
    Set rdServices = dbChar2.OpenRecordset("SELECT * FROM TestServices")

    For intRecords = 0 To rdServices.RecordCount - 1
        .Size = 40
        .Color = RGB(80, 60, 50)
        Me.Content.InsertAfter vbCrLf

        .Size = 20
        .Color = RGB(0, 0, 0)
        Me.Content.InsertAfter Text:=rdServices.Fields(0).Value
        Me.Content.InsertAfter Text:=rdServices.Fields(3).Value
        Me.Content.InsertAfter Text:=rdServices.Fields(4).Value
                If intRecords < rdServices.RecordCount - 1 Then
                     Me.Content.InsertAfter Chr(12)
                End If

    Next intRecords

    Friday, May 18, 2012 1:33 PM