469,276 Members | 1,746 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,276 developers. It's quick & easy.

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
atable.Select
If MsgBox("This one?", vbYesNo) = vbYes Then
Selection.Rows.ConvertToText Separator:=wdSeparateByDefaultListSeparator, _
NestedTables:=True

End If
Next atable
Dec 20 '11 #1
1 1751
Killer42
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
  20.  
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
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.