Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #7  
Old 11-23-2023, 05:16 AM
gmaxey gmaxey is offline Deleting specific strings of characters in specific positions Windows 10 Deleting specific strings of characters in specific positions Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

What specifically are you trying to do? If you want to insert a line break before " (about" then:


Code:
Sub ScratchMacro()
'A basic Word Macro coded by Gregory K. Maxey
Dim oRng As Range
  Set oRng = ActiveDocument.Range
  With oRng.Find
    .Text = " (about"
    If .Execute Then
      oRng.Characters(1).Delete
      oRng.InsertBefore Chr(11)
    End If
  End With
lbl_Exit:
  Exit Sub
End Sub

In your existing code, the .Execute is only going return True once because after the first find, oRng IS the found text and the found text is the text you want to find.



Type this sentence in a select a word document and then run:


Code:
Sub Demo()
Dim oRng As Range
  Set oRng = Selection.Range
  With oRng.Find
    .Text = Selection.Text
    If .Execute Then
      MsgBox "Found"
    Else
      MsgBox "I can't find myself when I AM the defined search range."
    End If
  End With
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting specific strings of characters in specific positions Word macro for deleting a line that starts with a specific character + deleting the line before eduardb Word 1 08-10-2022 03:17 AM
Search Word for specific strings and replace with hyperlinks from a list jlive24 Word VBA 2 06-26-2022 08:14 PM
Extracting Specific Text Strings PWH68 Word VBA 6 10-08-2019 02:07 AM
Deleting specific strings of characters in specific positions Deleting Characters in a specific location in Word 2010 ppayaw Word VBA 8 12-13-2016 08:11 AM
Deleting specific strings of characters in specific positions update style of all strings available between two specific strings vikrantkale Word 1 03-28-2011 06:13 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:46 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