Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Split currently selected table into several tables based on number of rows using VBA

Posted on 2014-04-02
3
Medium Priority
?
1,497 Views
Last Modified: 2014-04-03
Dear Experts:

for the currently selected table I would like to run the following action using VBA:

Split the current table into several tables, i.e each row is converted into a single table with manual page breaks in between these newly created tables.

Example: currently selected table has 5 rows. After running the macro, 5 individual tables are created with 4 manual page breaks in between.

Help is much appreciated. Thank you very much in advance.

Regards, Andreas
0
Comment
Question by:AndreasHermle
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 53

Accepted Solution

by:
Rgonzo1971 earned 2000 total points
ID: 39972325
Hi,

pls try

Sub Macro()

Set tbl = ActiveDocument.Tables(1)

For Idx = tbl.Rows.Count To 2 Step -1
    tbl.Cell(Idx, 1).Range.Select
    Selection.SplitTable
    Selection.InsertBreak Type:=wdPageBreak
Next
 With ActiveDocument.Content.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Text = Chr(13) & Chr(12) & Chr(13)
  .Replacement.Text = Chr(12)
  .Forward = True
  .Format = False
  .Execute Replace:=wdReplaceAll  ' <-- Use wdReplaceAll if required
End With
End Sub

Open in new window

EDIT Delete Paragraph Marks

Regards
0
 

Author Comment

by:AndreasHermle
ID: 39974347
Hi Rgonzo,

this macro works just great. Thank you very much for your great and professional support.

I slightly tweaked the code:

Line 3: Set tbl = Selection.Tables(1)

Regards, Andreas
0
 

Author Closing Comment

by:AndreasHermle
ID: 39974360
as always, professional solution provided by you.

Thank you very much. Regards, Andreas
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is often necessary in this forum and others to illustrate Word fields as text with the field delimiters replaced with the curly brackets that the delimiters resemble when field codes are being displayed on the document. This means that the text c…
I'm writing to share my clumsy experience in using this elegant tool so you can avoid every stupid mistake I made. (I leave it to the authorities to decide if this deserves a place in the Knowledge archives.)  Now that I am on the other side of my l…
This Micro Tutorial well show you how to find and replace special characters in Microsoft Word. This is similar to carriage returns to convert columns of values from Microsoft Excel into comma separated lists.
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question