Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-27-2019, 08:05 AM
scienceguy scienceguy is offline Ignore Table and Table Caption For Revisions Windows 10 Ignore Table and Table Caption For Revisions Office 2016
Advanced Beginner
Ignore Table and Table Caption For Revisions
 
Join Date: Feb 2019
Posts: 46
scienceguy is on a distinguished road
Default Ignore Table and Table Caption For Revisions


Hello,

I am working on an application in Word vba, whereby I am extracting the revisions to a document after using Word's "track changes" feature. However, as I pull out the revisions, I want to omit tables and table captions. I figured out to omit the tables, but I can't figure out how to omit the table captions. Here is the code snippet I have so far:

Code:
For i = 1 To wdDoc.Paragraphs.Count
        If Not wdDoc.Paragraphs(i).Range.Information(wdWithInTable) Then

		'process revisions

	End if
Next i
Thank you in advance for any help!

Roy
Reply With Quote
  #2  
Old 08-27-2019, 11:02 AM
gmaxey gmaxey is offline Ignore Table and Table Caption For Revisions Windows 10 Ignore Table and Table Caption For Revisions Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

The code you posted shows nothing about "omitting" tables.

If you want to remove "Table" captions and those captions stand alone in its parent paragraphs, you can use:


Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oFld As Field
  For Each oFld In ActiveDocument.Fields
    If oFld.Type = wdFieldSequence Then
      'See if it is a Table caption sequence field
      If InStr(oFld.Code, "Table") <> 0 Then
        oFld.Code.Paragraphs(1).Range.Delete
      End If
    End If
  Next oFld
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 08-27-2019, 11:20 AM
scienceguy scienceguy is offline Ignore Table and Table Caption For Revisions Windows 10 Ignore Table and Table Caption For Revisions Office 2016
Advanced Beginner
Ignore Table and Table Caption For Revisions
 
Join Date: Feb 2019
Posts: 46
scienceguy is on a distinguished road
Default Ignore Table and Table Caption For Revisions Reply to Thread

Thanks, Greg, for the code. However, I was confused by your comment, "The code you posted shows nothing about "omitting" tables." I thought the following line would skip the paragraph if it was a table? No?

If Not wdDoc.Paragraphs(i).Range.Information(wdWithInTabl e)
Reply With Quote
  #4  
Old 08-27-2019, 06:34 PM
gmaxey gmaxey is offline Ignore Table and Table Caption For Revisions Windows 10 Ignore Table and Table Caption For Revisions Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

I thought you wanted to omit (delete tables) and omit (delete table captions). Try this:

Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim i As Long
Dim wdDoc As Document
  Set wdDoc = ActiveDocument
  For i = 1 To wdDoc.Paragraphs.Count
  If Not wdDoc.Paragraphs(i).Range.Information(wdWithInTable) Then
    If wdDoc.Paragraphs(i).Range.Fields.Count > 0 Then
      If Not fcnEvalForTableCaption(wdDoc.Paragraphs(i).Range) Then
        'Process
      End If
    Else
       'Process
    End If
    
   'process revisions
  End If
Next i

lbl_Exit:
  Exit Sub
  
End Sub

Function fcnEvalForTableCaption(oRng As Range)
Dim oFld As Field
  fcnEvalForTableCaption = False
  For Each oFld In oRng.Fields
    If oFld.Type = 12 Then
      If InStr(oFld.Code, "Table") Then
        fcnEvalForTableCaption = True
        Exit For
      End If
    End If
  Next
End Function
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #5  
Old 08-28-2019, 03:18 AM
scienceguy scienceguy is offline Ignore Table and Table Caption For Revisions Windows 10 Ignore Table and Table Caption For Revisions Office 2016
Advanced Beginner
Ignore Table and Table Caption For Revisions
 
Join Date: Feb 2019
Posts: 46
scienceguy is on a distinguished road
Default

Many thanks, Greg!
Reply With Quote
Reply

Tags
track changes; word



Similar Threads
Thread Thread Starter Forum Replies Last Post
Ignore Table and Table Caption For Revisions Question about table caption problem Teaboar Word 8 08-22-2019 06:25 AM
Ignore Table and Table Caption For Revisions Connecting a Table Caption to the table MikeD Word Tables 2 06-22-2014 10:56 AM
Ignore Table and Table Caption For Revisions How to make the Caption and its text have the same width as the table? Jamal NUMAN Word 1 04-24-2011 06:44 PM
Ignore Table and Table Caption For Revisions Caption and Table of Figures issue reece22345 Word 3 04-15-2011 12:18 AM
Spacing between table and caption EtienneOBrien Word Tables 0 12-27-2008 01:58 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:42 AM.


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