Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-30-2021, 10:46 AM
riovio riovio is offline Delete paragraph if bookmark contains a certain wording Windows 7 64bit Delete paragraph if bookmark contains a certain wording Office 2019
Novice
Delete paragraph if bookmark contains a certain wording
 
Join Date: Oct 2021
Posts: 1
riovio is on a distinguished road
Default Delete paragraph if bookmark contains a certain wording

Hello there,

I am looking for a VBA to delete an entire paragraph if a paragraph contains the word "not-specified". I have attached a sample doc (have highlighted the "not-specified" here).

Would be cool if someone has got an idea how to solve this!
Attached Files
File Type: docx testdoc.docx (12.3 KB, 7 views)
Reply With Quote
  #2  
Old 10-30-2021, 09:11 PM
Guessed's Avatar
Guessed Guessed is offline Delete paragraph if bookmark contains a certain wording Windows 10 Delete paragraph if bookmark contains a certain wording Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Try this code
Code:
Sub NonSpecificKiller()
  Dim aRng As Range
  Set aRng = ActiveDocument.Range
  With aRng.Find
    .ClearFormatting
    .Text = "not-specified"
    .MatchCase = False
    Do While .Execute
      aRng.Paragraphs(1).Range.Delete
    Loop
  End With
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete paragraph if bookmark contains a certain wording Find word, Insert Paragraph and bookmark gattaca714 Word VBA 2 03-24-2017 09:23 PM
Delete paragraph if bookmark contains a certain wording Alignment of wording at the top of the line space charles_cat Word 1 03-03-2015 02:58 AM
Delete paragraph if bookmark contains a certain wording Delete bookmark and paragraph which is blank dsjk9190 Word VBA 2 01-22-2015 01:15 AM
Delete paragraph if bookmark contains a certain wording Calculate the coordinates of a DocVariable, Bookmark or paragraph. MaxInCO Word VBA 5 12-11-2013 03:28 PM
Delete paragraph if bookmark contains a certain wording Delete Range After Bookmark? VBA_Elfe Word VBA 3 04-05-2013 05:05 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