View Single Post
 
Old 04-11-2023, 12:24 PM
Italophile Italophile is offline Windows 11 Office 2021
Expert
 
Join Date: Mar 2022
Posts: 554
Italophile is just really niceItalophile is just really niceItalophile is just really niceItalophile is just really nice
Default

Quote:
Originally Posted by ctviggen View Post
Hmm...not sure why that looks bad. Anyway, the Replace:=wdReplaceAll is outside the original with..end with "loop", instead of being inside the loop.
Firstly, there isn’t a “Loop” in your code, nor is there an “End With”

“With … End With” is referred to as a “With Block”, and is an efficient way of referring to an object without having to repeat the object each time you set a property.

“Selection.Find” does not do anything until the “.Execute”, which may be within the With block or outside it, especially if it is being called inside a loop, in which case it would appear as
Code:
Do While Selection.Find.Execute
    ‘Do stuff
Loop
Reply With Quote