Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-05-2015, 12:47 PM
frustrated teacher frustrated teacher is offline Macro Needed to delete Unwanted paragraphs within a table. Windows 7 64bit Macro Needed to delete Unwanted paragraphs within a table. Office 2010 64bit
Novice
Macro Needed to delete Unwanted paragraphs within a table.
 
Join Date: May 2014
Posts: 12
frustrated teacher is on a distinguished road
Default Macro Needed to delete Unwanted paragraphs within a table.

I want to be able to delete the last paragraph within a table. After running several macros I am left with a table with just 3 paragraphs.

I have attached a sample BEFORE the macros are applied and a sample of what it looks like AFTER the macros are applied.



I tried the following code and it does not seem to work.

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
Attached Files
File Type: docx sample files.docx (12.3 KB, 9 views)
File Type: docx sample files after macro.docx (12.0 KB, 11 views)
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro Needed to delete Unwanted paragraphs within a table. Word thinks 1 sentence is 2 paragraphs and won't let me delete the extra paragraph symbol jrasicmark Word 1 12-05-2014 01:50 AM
Macro Needed to bold specific lines and Macro to turn into CSV anewteacher Word VBA 1 05-28-2014 03:59 PM
Macro Needed to delete Unwanted paragraphs within a table. Macro Needed to delete Unwanted paragraphs in series frustrated teacher Word VBA 1 05-02-2014 03:32 PM
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

Other Forums: Access Forums

All times are GMT -7. The time now is 06:55 AM.


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