View Single Post
 
Old 10-17-2014, 07:25 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,366
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

Quote:
Originally Posted by CircleG View Post
I also have a combined macro with several macros to run at the same time that I need to update all the tables in the document. I tried puting the new code in the combined macro, but that didn't work. So I tried putting it in each macro in the combined macro, but I keep getting error messages and not all the macros are running. To say I'm not real good at this is putting it mildly.
The first thing you need to do is to fix the errors in your code. Even as stand-along macros, your ReplaceParagraphMarks and RemoveHeaders macros won't run. Both are missing:
Code:
    End With
  Next oTbl
If you then look at your ReplaceParagraphMarks, RemoveHeaders and RemoveBorders macros, you'll see that all have this much in common:
Code:
Dim oTbl As Word.Table
For Each oTbl In ActiveDocument.Tables
  With oTbl
    
  End With
Next oTbl
If you wanted to combine those three macros, all you need is the above code, plus whatever's between the With ... End With parts from each of those three macro (and, of course, a sub to contain all the code). That said, there are some other issues you need to address with the ReplaceParagraphMarks and RemoveHeaders macros, too. For example:
Selection.Rows.HeadingFormat = wdToggle
would only work on a Selection (i.e. something that is selected), but your code isn't selecting anything (and doesn't need to). Furthermore, it would actually add a header row if a selected row wasn't already one... Being inside a loop only means it'll keep toggling the same selection's header property on/off. Similarly, your Find/Replace code operates completely independently of any tables that it might be in - it works on the entire document. All that happens is that the loop keeps running the same document-wide process.

Finally, if you want to keep the macros separate, you could change lines like:
Application.Run MacroName:="ReplaceBullets"
to just:
ReplaceBullets
or, to make it more apparent another sub is being called:
Call ReplaceBullets
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote