View Single Post
 
Old 05-28-2017, 05:59 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2013
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,164
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

I've made lots of assumptions based on the content you provided in your sample document. If any of those assumptions are incorrect in your other docs then those need to be resolved. For instance, I assume that the last table in the document is where the references are sitting.

In my testing, the last table would have been ignored in the table loop (since it didn't trigger any of the If tests) and then the following code should address it directly
Code:
  With ActiveDocument.Tables(ActiveDocument.Tables.Count)
    Debug.Print sRefs
    For Each aRow In .Rows
      sTag = Split(aRow.Cells(1).Range.Text, vbCr)(0)
      'Debug.Print sTag
      aRow.Range.Font.Hidden = Not InStr(sRefs, sTag) > 0
    Next aRow
  End With
Try stepping through this section of the code to see if you can work out why it isn't working in your document. Maybe add a couple of lines of code to reveal the entire table before looping through the rows eg.
Code:
  With ActiveDocument.Tables(ActiveDocument.Tables.Count)
    Debug.Print sRefs
    .Range.Font.Hidden = False
    .Select
    For Each aRow In .Rows
      sTag = Split(aRow.Cells(1).Range.Text, vbCr)(0)
      'Debug.Print sTag
      aRow.Range.Font.Hidden = Not InStr(sRefs, sTag) > 0
    Next aRow
  End With
Note: your code solution of adding ActiveDocument.Range.Font.Hidden = False will reveal the entire document, not just the last table
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote