+ Reply to Thread
Results 1 to 4 of 4

Use Excel VBA to change font color of word in Word document

Hybrid View

  1. #1
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Use Excel VBA to change font color of word in Word document

    Maybe :
    Sub Test()
      Const wdReplaceNone = 0
      Const wdReplaceOne = 1
      Const wdReplaceAll = 2
      Dim objApp As Object, objDoc As Object
    
      Set objApp = CreateObject("Word.Application")
          Set objDoc = objApp.Documents.Open(ThisWorkbook.Path & "\MyWordDoc.doc")
              With objDoc.Content.Find
                 .ClearFormatting
                 With .Replacement
                    .ClearFormatting
                    .Font.Color = vbRed
                 End With
                '.Execute FindText:="*", ReplaceWith:="*", Format:=True, Replace:=wdReplaceAll
                .Execute FindText:="*", Format:=True, Replace:=wdReplaceAll
              End With
          objDoc.Close True
      objApp.Quit
    End Sub
    Attached Files Attached Files
    1. I care dog
    2. I am a loop maniac
    3. Forum rules link : Click here
    3.33. Don't forget to mark the thread as solved, this is important

  2. #2
    Registered User
    Join Date
    06-13-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Use Excel VBA to change font color of word in Word document

    This code worked for me. Thank you very much!

    PHP Code: 
        With objDoc.Content.Find
            
    .ClearFormatting
            With 
    .Replacement
                
    .ClearFormatting
                
    .Font.Color vbRed
            End With
            
    .Execute FindText:="*"Format:=TrueReplace:=wdReplaceAll
        End With 

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Help! change lots of word document font format.
    By 302 in forum Word Programming / VBA / Macros
    Replies: 10
    Last Post: 06-05-2022, 10:37 PM
  2. Help! change lots of word document font format.
    By 302 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-04-2022, 05:21 AM
  3. Replies: 5
    Last Post: 10-10-2021, 11:49 PM
  4. How do i make the word remove change to font color red. This is outlook vba
    By ioo_ares_ooi in forum Outlook Programming / VBA / Macros
    Replies: 4
    Last Post: 06-11-2019, 11:44 AM
  5. How do i make the word remove change to font color red. This is outlook vba
    By ioo_ares_ooi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-11-2019, 11:35 AM
  6. Find a word and change font color
    By bbqmikeq in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 12-28-2012, 12:43 PM
  7. Replies: 3
    Last Post: 03-05-2012, 11:03 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1