troubleshooting Question

Skip Tables in VBA macro

Avatar of PatternNut
PatternNut asked on
Microsoft Word
5 Comments1 Solution1263 ViewsLast Modified:
I have a macro that looks through each paragraph in a document, like so:

Dim para as Paragraph
For each para in ActiveDocument.Paragraphs
a = a + 1
run code
etc

However, if there is a table in the document then it naturally looks through each cell of the table separately.   I don't want it to look at tables, so if there are lots of tables in the document, I'm running lots of unnecessary iterations! I forget my exact solution, but it was something like this...

If ActiveDocument.Paragraphs(a).Range.Tables.Count > 0 Then next paragraph
Else
Run lots of code

That checks each paragraph to see if it's in a table... if it is then it skips to next paragraph and checks there.  But is there any way to make it skip straight to the end of the table?  I do not want to use 'select' because it will cause complications later on.

Thanks,

PatternNut

ASKER CERTIFIED SOLUTION
GrahamSkan
Retired
Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros