Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 01-12-2018, 02:48 AM
warddegeest warddegeest is offline Using VBA to delete text between two words Windows 10 Using VBA to delete text between two words Office 2016
Novice
Using VBA to delete text between two words
 
Join Date: Jan 2018
Posts: 1
warddegeest is on a distinguished road
Default Using VBA to delete text between two words

I have a text, and I want to delete the text between the words "Alfa" and "Brava".



I tried something as this, it displayes the text between, but does not delete this.


Dim rng1 As Range
Dim rng2 As Range
Dim strTheText As String
Set rng1 = ActiveDocument.Range
If rng1.Find.Execute(FindText:="Alfa") Then
Set rng2 = ActiveDocument.Range(rng1.End, ActiveDocument.Range.End)
If rng2.Find.Execute(FindText:="Brava") Then
strTheText = ActiveDocument.Range(rng1.End, rng2.Start).Text
MsgBox strTheText
End If

Any help would be appreciated.

Ward
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete Text from Insertion Point to Found Text feenyman99 Word 0 04-17-2016 05:40 PM
Microsoft Word macro to find text, select all text between brackets, and delete helal1990 Word VBA 4 02-05-2015 03:52 PM
Using VBA to delete text between two words How to find and delete duplicate words in doc cinvest Word 1 09-29-2014 08:34 PM
Words are being duplicated in text boxes argentraven PowerPoint 0 07-24-2014 03:10 PM
Using VBA to delete text between two words Remove text between two words VeeCee Word VBA 7 01-05-2014 03:39 PM

Other Forums: Access Forums

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