Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-10-2012, 12:38 AM
macropod's Avatar
macropod macropod is offline Macro for MS Word Windows 7 64bit Macro for MS Word Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,526
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

Try:
Code:
Sub CleanTables()
Application.ScreenUpdating = False
Dim oTbl As Table, Rng As Range, i As Long, j As Long, StrTmp As String
With ActiveDocument
  For Each oTbl In .Tables
    With oTbl
      j = .Columns.Count
      For i = .Rows.Count To 1 Step -1
        With .Rows(i)
          If .Cells.Count > 1 Then
            Set Rng = .Range
            Rng.Start = .Cells(2).Range.Start
            StrTmp = Replace(Replace(Replace(Replace(Rng.Text, Chr(7), ""), vbCr, ""), " ", ""), "0", "")
            If StrTmp = "" Then .Delete
          End If
        End With
      Next
    End With
  Next
End With
Application.ScreenUpdating = True
End Sub

__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #2  
Old 04-10-2012, 04:18 PM
ubns ubns is offline Macro for MS Word Windows 7 32bit Macro for MS Word Office 2010 32bit
Competent Performer
Macro for MS Word
 
Join Date: Apr 2012
Posts: 177
ubns is on a distinguished road
Default

Hi Paul,

Thanks for this extensive code.

When I run this code: its gives the run time error - 5991 - cannot access individual rows in this collection because the table has vertically merged cells.

PS - When I click on debug --- it stop to execute code (as expected) and highlights the sentence in the code (as expected again), indicating the possible source of error.

However, when I click on End - it delete the rows with zero.

So with my limited knowledge may be there is a need to include exception handling or something. Anyways I am just guessing.

Mate also I wanted to ask you, which is the best source for beginners to learn all this. You seem to have so much knowledge, its awesome and quite amazing.

Do you also have forums for excel?
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro in word khalfenadeem Word 1 04-11-2011 04:35 PM
Macro for MS Word Help with Word macro please Philcraig69 Word VBA 2 01-21-2011 04:19 PM
Print Macro in MS Word steve207 Word VBA 0 09-10-2010 02:11 AM
Word 2003 macro to Word 2007 to 2010 to... maruapo Word VBA 0 06-04-2010 03:43 PM
Word macro weezypenguin Word 0 02-25-2010 01:25 PM

Other Forums: Access Forums

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