[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

VBA to remove a specific paragraph from word document

Posted on 2016-11-02
4
Medium Priority
?
42 Views
Last Modified: 2016-11-03
I have a document with too many paragraphs repeated as shown in the attached workbook.

in the attached word i have the paragraph that i need to get red of regardless in which page it is.

can this be automated with VBA?
EE.docx
0
Comment
Question by:excelismagic
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 53

Accepted Solution

by:
Rgonzo1971 earned 2000 total points
ID: 41871627
Hi,

pls try

Sub LongStringFindReplace()
Dim oSourceDoc As Document
Dim srchTxt As String
Dim replaceRng As Range
Dim i As Long
  srchTxt = Selection.Range.Text
  ActiveDocument.Range(0, 0).Select
  If Len(srchTxt) > 250 Then
    With Selection.Find
      .Text = Left(srchTxt, 250)
      .Forward = True
      .Wrap = wdFindContinue
      Do While .Execute
        Do While srchTxt Like Selection.Text & "*"
            If Selection.Text = srchTxt Then
                Selection.Delete
                Exit Do 'loop
            End If
            Selection.MoveEnd Unit:=wdCharacter, Count:=1
        Loop
      Loop
    End With
  Else
    With Selection.Find
      .Text = srchTxt
      .Replacement.Text = ""
      .Forward = True
      .Wrap = wdFindContinue
      .Execute Replace:=wdReplaceAll
    End With
  End If
End Sub

Open in new window

Regards
0
 
LVL 3

Author Comment

by:excelismagic
ID: 41871870
thanks very much Rgonzo1971 but it did not solve the problem

here is part of the full document attached.

i am trying to remove the part shown in screenshot below from this file and the macro i ran, did not fix it.
 
EE.pngEE.docx
0
 
LVL 53

Expert Comment

by:Rgonzo1971
ID: 41871877
pls select the part you want to delete before running the code
0
 
LVL 3

Author Closing Comment

by:excelismagic
ID: 41872428
thanks.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The code described here does no longer work. Please see replacement Article: http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/A_3887-Getting-your-EE-Ranking-statistics-in-Excel-The-Next-Generation.html (http…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question