Hiding a Paragraph based on its first word

J

JuanManuel

Hi,
If I have something like this in a single cell of a table:

MI: Dimensional inspection. Measure Tangency Angles

HGP: Dimensional inspection. Measure Tangency Angles

CI: Dimensional inspection. Measure Tangency Angles

How do I code a macro to hide only the paragraph starting with "MI" for
example??

Thank you,

Juan Manuel
 
S

Shasur

Here is a hint for that Juan

Sub Search_Specific_TextIn_Tables()

Dim MyTab As Table
Dim sCellText
Dim bTextFound As Boolean


Set MyTab = ActiveDocument.Tables(1)

For I = 1 To 1 ' MyTab.Columns.Count
bTextFound = False
For j = 1 To MyTab.Rows.Count
sCellText = Trim$(MyTab.Cell(j, 1).Range.Text)

' You need to trim the characters and then do the checking

' Here do the checking
If Len(sCellText) <> 0 And InStr(1, sCellText, "MI") = 1 Then
MyTab.Rows(j).Range.Font.Hidden = True
End If
Next j
Next I

End Sub

I have assumed that you are searching for 'MI' in first column. If you want
for all columns please replace

For I = 1 To 1 ' MyTab.Columns.Count

with

For I = 1 To MyTab.Columns.Count

Cheers
 
S

StevenM

To: JuanManuel,

Sub HideCell()
Dim oRange As Range
Dim oTable As Table
Dim oCell As Cell

For Each oTable In ActiveDocument.Tables
For Each oCell In oTable.Range.Cells
If Left(oCell.Range.Text, 3) = "MI:" Then
oCell.Range.Font.Hidden = True
End If
Next oCell
Next oTable
End Sub

The above searches every cell in every table in the active document for a
cell beginning with "MI:" and hides the information in that cell.

Steven Craig Miller
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top