473,386 Members | 1,721 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,386 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
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 1862
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

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

Similar topics

10
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...
0
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
0
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...
0
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.
7
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.
5
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...
1
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...
0
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...
0
by: nkg6971 | last post by:
Hi All, Is there anyway to execute a excel macro from ms word macro? Code requested. Thanks in advacne.
0
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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.