Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 10-30-2020, 06:32 AM
Ulodesk Ulodesk is offline Macro to strip table styles, please Windows 10 Macro to strip table styles, please Office 2016
Word 2013 Expert Cert
Macro to strip table styles, please
 
Join Date: Sep 2009
Location: Virginia
Posts: 872
Ulodesk is on a distinguished road
Default Macro to strip table styles, please

Some years ago, someone here wrote me a macro to copy just the tables in a Word document and paste then into a new one. The purpose of this is to be able to reformat these tables with a custom table style and apply para styles, as necessary, local formatting, before replacing the tables in the original document with the new ones.

A further step that could be very useful would be replacing the table styles in the new document with the style upon which our custom tables are based, namely, Table Grid. (There are a bunch of MS built-in Table Grid styles, numbered, "light," etc.; I used plain Table Grid, finding it more amenable that Normal.)

I am guessing that this action could be added to the existing macro (see below).

One additional option that would be nice, if possible, would be a separate action to clear text styles. I say option, because, while usually the simplest path is to strip them all and apply the custom paragraph styles, there are times when in long tables, when text and bulleted paragraphs are frequently interspersed, it can be easier to leave bulleted paragraphs bulleted so that finding them is easier. This action might therefore be set off by apostrophe paragraphs and a description line, so that the user could disable that particular part of the macro when desired. (The only way I know to do this is to start each action line with an apostrophe; I'm assuming it would not be many lines long; I'm no coder.)

Would someone be willing to provide this?

Code:
Sub CopyTables()
    Dim Source As Document
    Dim Target As Document
    Dim tbl As Table
    Dim tr As Range

    Set Source = ActiveDocument
    Set Target = Documents.Add

    For Each tbl In Source.Tables
        Set tr = Target.Range
        tr.Collapse wdCollapseEnd
        tr.FormattedText = tbl.Range.FormattedText
        tr.Collapse wdCollapseEnd
        tr.Text = vbCrLf
    Next
End Sub

Reply With Quote
 

Tags
strip styles, table styles



Similar Threads
Thread Thread Starter Forum Replies Last Post
strip characters from the right jon.fallows@sedgman.com Excel 3 05-09-2018 11:38 PM
Macro to strip table styles, please Format shelf strip graphic and data ShaunO Mail Merge 1 08-19-2016 04:20 PM
Macro to strip table styles, please Heading row disappears from table styles when pasted table is selected andrewballem Word Tables 2 11-12-2013 05:18 AM
Macro to strip table styles, please strip extra information from email addresses jbk1043 Word 1 03-03-2013 01:46 PM
Macro to strip table styles, please Strip lf/cr from text p3aul Word 9 08-18-2009 12:42 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:00 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft