Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 10-30-2020, 01:14 PM
gmaxey gmaxey is offline Macro to strip table styles, please Windows 10 Macro to strip table styles, please Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,636
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Code:
Sub CopyTables() Dim oDoc As Document Dim oDocTarget As Document Dim oTbl As Table, oTblTarget As Table Dim oRng As Range   Set oDoc = ActiveDocument   Set oDocTarget = Documents.Add   For Each oTbl In oDoc.Tables     Set oRng = oDocTarget.Range     With oRng       .Collapse wdCollapseEnd       oRng.FormattedText = oTbl.Range.FormattedText       Set oTblT = oRng.Tables(1)       oTblT.Style = "Table Grid"       .Collapse wdCollapseEnd       .Text = vbCrLf     End With   Next
   'It is called stet:   'oDocTarget.Range.Select   'Selection.ClearFormatting   'Selection.Collapse wdCollapseStart   oDoc.Activate lbl_Exit:   Exit Sub End Sub
[moderator attempt to reformat - think I got it right - CK ]



Code:
Sub CopyTables()
   Dim oDoc As Document
   Dim oDocTarget As Document 
   Dim oTbl As Table, oTblTarget As Table 
   Dim oRng As Range   
   Set oDoc = ActiveDocument   
   Set oDocTarget = Documents.Add   
   For Each oTbl In oDoc.Tables     
      Set oRng = oDocTarget.Range     
      With oRng
        .Collapse wdCollapseEnd
        .FormattedText = oTbl.Range.FormattedText
         Set oTblT = oRng.Tables(1)
         oTblT.Style = "Table Grid"
        .Collapse wdCollapseEnd
        .Text = vbCrLf
     End With
   Next
   'It is called 
stet:
   'oDocTarget.Range.Select
   'Selection.ClearFormatting
   'Selection.Collapse wdCollapseStart
   oDoc.Activate
lbl_Exit:
   Exit Sub 
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/

Last edited by Charles Kenyon; 11-02-2020 at 04:39 PM.
Reply With Quote
 

Tags
strip styles, table styles

Thread Tools
Display Modes


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 07:51 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