472,119 Members | 1,511 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

Word VBA to run macro two page then skip third

Hi everyone,

I am trying to write a Word macro that will convert tables to text on the first two pages of a document, while skipping the third page (out of 600+ pages). So, for example, it would select pages 1, 2, 4, 5, 7, 8, 10, 11 ...
and convert everything on it from tables to text.

Here's the code so far for the conversion, but I am lost as how to implement it all together...

Thanks for any help!

Sub RipOutTables()
' RipOutTables Macro
' Macro to find and delete tables
For Each atable In ActiveDocument.Tables
If MsgBox("This one?", vbYesNo) = vbYes Then
Selection.Rows.ConvertToText Separator:=wdSeparateByDefaultListSeparator, _

End If
Next atable
Dec 20 '11 #1
1 1802
8,435 Expert 8TB
Do you have one table per page?

If so, then all you need is to keep count and skip every 3rd table. Something along these lines perhaps...
Expand|Select|Wrap|Line Numbers
  1. Sub RipOutTables()
  2. '
  3. ' RipOutTables Macro
  4. ' Macro to find and delete tables
  5. '
  6. Dim I As Long
  7. For Each atable In ActiveDocument.Tables
  8.   I = I + 1
  9.   If I = 3 Then
  10.     I = 0
  11.   Else
  12.     atable.Select
  13.     If MsgBox("This one?", vbYesNo) = vbYes Then
  14.       Selection.Rows.ConvertToText _
  15.           Separator:=wdSeparateByDefaultListSeparator, _
  16.           NestedTables:=True
  17.     End If
  18.   End If
  19. Next
Dec 23 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

10 posts views Thread by Brian Kwan | last post: by
reply views Thread by Merdex | last post: by
reply views Thread by incisions | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.