Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-02-2014, 04:32 AM
frustrated teacher frustrated teacher is offline Macro Needed to delete Unwanted paragraphs in series Windows 7 64bit Macro Needed to delete Unwanted paragraphs in series Office 2010 64bit
Novice
Macro Needed to delete Unwanted paragraphs in series
 
Join Date: May 2014
Posts: 12
frustrated teacher is on a distinguished road
Default Macro Needed to delete Unwanted paragraphs in series

Hello all!

In a previous post (https://www.msofficeforums.com/word-...le-choice.html) I had great help and this is a follow up request:



Is it possible to have a macro delete particular paragraphs within a table that are in a series (sorry, I apologize if I used the wrong terminology). I have included a sample with the current formatting.


94.Test Question A




E. Answer

*delete this portion ->Long long long long long explaination. Long long long long long explaination. Long long long long long explaination. Long long long long long explaination. Long long long long long explaination. <-delete this portion*
Attached Files
File Type: docx sample question.docx (13.9 KB, 12 views)
Reply With Quote
  #2  
Old 05-02-2014, 03:32 PM
macropod's Avatar
macropod macropod is offline Macro Needed to delete Unwanted paragraphs in series Windows 7 32bit Macro Needed to delete Unwanted paragraphs in series Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

For that, you could use a macro like:
Code:
Sub UpdateTables()
Application.ScreenUpdating = False
Dim Tbl As Table, Rng1 As Range, Rng2 As Range
With ActiveDocument
  For Each Tbl In .Tables
    With Tbl
      If .NestingLevel = 1 Then
        Set Rng1 = .Cell(1, 1).Range
        With Rng1
          .End = .End - 1
          If (.Text Like "#.") Or (.Text Like "##.") Or (.Text Like "###.") Then
            Set Rng2 = .Rows(1).Cells(2).Range
            With Rng2
              .End = .End - 1
              While .Paragraphs.Last.Range.Tables(1).NestingLevel = 1
                .Paragraphs.Last.Range.Text = vbNullString
              Wend
            End With
          End If
        End With
      End If
    End With
  Next
End With
Set Rng1 = Nothing: Set Rng2 = Nothing
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro Needed to Delete Unneeded Answers in Multiple Choice Format Question frustrated teacher Word VBA 6 05-02-2014 03:37 AM
Delete lots of empty space between paragraphs. FieldTechnician Word 4 10-25-2013 01:14 PM
Macro Needed to delete Unwanted paragraphs in series Is the a way to delete the "empty" paragraphs? Jamal NUMAN Word 3 07-27-2011 04:19 AM
Select Series Color - Macro judicial85 Excel Programming 0 03-14-2011 02:35 PM
Macro Needed to delete Unwanted paragraphs in series Eliminate paragraph breaks geobruin Word 1 06-12-2009 06:55 AM

Other Forums: Access Forums

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