Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Mar 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi there Everyone! This is my first post in this forum. Please try to help me if you can. My problem is probably very easy but it took me hours and hours and I still could not find a solution...

    My problem is the following:
    I have to open many many documents and have to search for two word combination. The combination is exactly the following: "Operational analysis". So I have to search the whole document for this string and if found then set its format to italic. Is there any vba code/macro which could do this automatically? It would help a lot! Thank you in advance for your help!

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Welcome to the Lounge!

    You could run the following macro in the active document:
    Code:
    Sub ReplaceInActiveDoc()
      With ActiveDocument.Content.Find
    	.ClearFormatting
    	.Replacement.ClearFormatting
    	.Text = "Operational analysis"
    	' ^& is the code for "whatever you entered in the Find what box"
    	.Replacement.Text = "^&"
    	.Replacement.Font.Italic = True
    	.Format = True
    	.Execute Replace:=wdReplaceAll
      End With
    End Sub
    It would be possible to process ALL Word documents in a folder - post back if you want that.

Posting Permissions

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