Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 07-19-2024, 02:40 AM
gmaxey gmaxey is offline find/replace from excel list to word doc not keeping original sentence case from excel list Windows 10 find/replace from excel list to word doc not keeping original sentence case from excel list Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,636
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Hello,


When you post code, it is helpful to simply post a snippet of the part that doesn't work. That way we don't have to try to recreate your entire situation (create and excel file etc.).


Try:


Code:
Sub format_scientific_names()
Dim oRng As Range
Dim strFind As String
  strFind = "Hyla cinerea"
  Set oRng = ActiveDocument.Range
  With oRng.Find
    .Text = strFind
    .Forward = True
    .Wrap = wdFindStop
    .MatchCase = False
    While .Execute
      oRng.Font.Italic = True
      oRng.Font.Bold = True
      oRng.Font.Color = RGB(200, 187, 0)
      oRng.Font.Name = "Times New Roman"
      oRng.Case = wdLowerCase
      oRng.Words(1).Characters(1).Case = wdUpperCase
      oRng.Collapse wdCollapseEnd
    Wend
  End With
  End Sub

Or you could simply use your Excel file "Find" phrase as the replacement text:


Code:
Sub format_scientific_names()
Dim oRng As Range
Dim strFind As String
  strFind = "Hyla cinerea"
  Set oRng = ActiveDocument.Range
  With oRng.Find
    .Text = strFind
    .Forward = True
    .Wrap = wdFindStop
    .MatchCase = False
    While .Execute
      oRng.Text = strFind
      oRng.Font.Italic = True
      oRng.Font.Bold = True
      oRng.Font.Color = RGB(200, 187, 0)
      oRng.Font.Name = "Times New Roman"
      oRng.Collapse wdCollapseEnd
    Wend
  End With
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
 

Tags
sentencecase



Similar Threads
Thread Thread Starter Forum Replies Last Post
find/replace from excel list to word doc not keeping original sentence case from excel list Find, Replace using Excel List pushpi004 Word VBA 16 02-20-2024 06:50 AM
Find and Replace from Predetermined list of Text for Both Find and Replace dminor Word VBA 1 08-16-2022 03:40 PM
find/replace from excel list to word doc not keeping original sentence case from excel list How to import list from Excel into drop-down list into word ahw Word VBA 43 02-28-2020 08:11 PM
find/replace from excel list to word doc not keeping original sentence case from excel list Advantages of List in Excel vs List in Word? Peace Freak Excel 3 04-08-2017 06:15 PM
find/replace from excel list to word doc not keeping original sentence case from excel list Having a Drop-down list in Word referring to an Excel list celias Word VBA 3 07-11-2016 11:40 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:39 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft