Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #16  
Old 12-04-2023, 08:20 AM
gmaxey gmaxey is offline Insert a condition in Find and Replace Windows 10 Insert a condition in Find and Replace Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Don't get rid of it completely. There are times that it must be used. See Learn to love ranges at:





VBA Basics
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #17  
Old 12-04-2023, 08:59 AM
RobiNew RobiNew is offline Insert a condition in Find and Replace Windows 10 Insert a condition in Find and Replace Office 2016
Competent Performer
Insert a condition in Find and Replace
 
Join Date: Sep 2023
Posts: 183
RobiNew is on a distinguished road
Default

Thank you, Gmaxey! I will certainly study that article. But for the time being here's another difficulty:
Code:
Dim aRng As Range
    For Each Paragraph In ActiveDocument.Paragraphs
NrPara = NoPara + 1
Set aRng = ActiveDocument.Paragraphs(NrPara).Range
If Paragraph.Range.ParagraphFormat.Alignment = wdAlignParagraphRight _
Or Paragraph.Range.ParagraphFormat.LeftIndent > 30 Then
aRng.Format.Font.Italic = False
End If
    Next Paragraph
    NrPara = 0
    Set aRng = Nothing
Reply With Quote
  #18  
Old 12-04-2023, 09:37 AM
gmaxey gmaxey is offline Insert a condition in Find and Replace Windows 10 Insert a condition in Find and Replace Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

You don't need a range object for that solution. You need a paragraph object.


30 what? centimeters, inches, yards, meters or points?
Code:
Sub ScratchMacro()
'A basic Word Macro coded by Gregory K. Maxey
Dim oPar As Paragraph
  For Each oPar In ActiveDocument.Paragraphs
    If oPar.Range.ParagraphFormat.Alignment = wdAlignParagraphRight _
      Or oPar.Range.ParagraphFormat.LeftIndent > 30 Then
      oPar.Range.Font.Italic = False
    End If
  Next oPar
lbl_Exit:
  Set oPar = Nothing
  Exit Sub
End Sub
Why do you declare some variables and not others? Do you have the Option Explicit statement at the top of your project module?
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #19  
Old 12-04-2023, 10:46 AM
RobiNew RobiNew is offline Insert a condition in Find and Replace Windows 10 Insert a condition in Find and Replace Office 2016
Competent Performer
Insert a condition in Find and Replace
 
Join Date: Sep 2023
Posts: 183
RobiNew is on a distinguished road
Default

Many thanks, Gmaxey! Of course you are right also for the declarations and the Option Explicit. The 30 in the code refers to points, which are my default measure.
Reply With Quote
Reply



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 01:39 PM.


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