473,372 Members | 1,076 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 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 1859
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

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

Similar topics

by: Brian Kwan | last post by:
Requirement: Call a Word Macro from ASP.NET with parameters Do anyone have idea about this? Please notice the import statement and sample code, as I am a beginner using ASP.NET, thanks for your...
by: Merdex | last post by:
Hi, I would like to print some data on template I created in word. How can I call an existing word macro and send some parameters to it from my VB 2005 application. Thanks in advance
by: deependrapathak | last post by:
Hi Everyone, I need to call a macro from msword document/template on a server to generate a new document using ASP page. There is a button on ASP page which will call a word macro to generate a...
by: vincent90152900 | last post by:
Can I use “Microsoft Word Macro” to send email? How to do that? This is discussion is open to suggestions. Many thanks for your replying.
by: vincent90152900 | last post by:
Is it possible to use a word macro to execute an .exe file? How to do that? This is discussion is open to suggestions. Many thanks for your replying.
by: fahadqureshi | last post by:
I am trying to write a word macro that scans the documents and highlights all the numbers that are less then .95 is this possible to do using a word macro? i guess i really only need the command...
by: mzmishra | last post by:
Hi , I ahve one word document "recovery.doc "which has a macro inside it. I need to run a daily job which will open this macro for me. I need the vbs code how to run the word macro. Can soem...
by: incisions | last post by:
Hi Guys, Im doing a Word macro that i want to count the number of standardized pages in my document. I would like the result to be shown and live updated in the statusbar (beside the word count...
by: nkg6971 | last post by:
Hi All, Is there anyway to execute a excel macro from ms word macro? Code requested. Thanks in advacne.
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.