Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 12-03-2023, 03:08 AM
vivka vivka is offline Insert a condition in Find and Replace Windows 7 64bit Insert a condition in Find and Replace Office 2016
Expert
 
Join Date: Jul 2023
Posts: 302
vivka is on a distinguished road
Default

Hi, RobiNew! Try this:
Code:
Sub Italicize_If()

Dim aRng As range
  For iType = 1 To 2
    Set aRng = ActiveDocument.StoryRanges(iType)
    With aRng.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .text = ""
        .Replacement.text = ""
        .Font.Italic = True
        .Forward = True
        .Wrap = wdFindStop
        .Format = True
        .MatchCase = False
        Do
           If .Execute And aRng.Characters.count < 30 Then
               aRng.Select
               selection.Style = "myItalic"
           End If
           aRng.Collapse wdCollapseEnd
        Loop While .found
    End With
  Next iType
lbl_exit:
Set aRng = Nothing 
Exit Sub
End Sub
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert a condition in Find and Replace Find & Replace to insert thousands separators jeffreybrown Word 3 10-19-2019 04:37 PM
Insert a condition in Find and Replace Find and replace condition norgro Word VBA 2 07-31-2015 06:38 AM
Insert a condition in Find and Replace Find and Replace - How to insert brackets around all numbers in a doc Natedogg Word 2 05-21-2015 07:16 AM
Insert a condition in Find and Replace Insert text at the end of a sentence Find/Replace AlmostFriday Word 6 06-17-2012 05:21 AM
Find & Replace Insert Issue mipacker Word 0 02-18-2009 08:59 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:47 AM.


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