Hi,

We have a legacy template (Word 2000) that uses paragraph styles in tables
(as that was the only way you could have table styles in 2000.). We also
have code that processes documents and looks for styles. In this case the
style is TFN (Table Footnote). If there is text w/i the cell tagged as TFN
then Selection.Find.Style = "TFN" will find the cell. However, if the celll
is empty (but the end of cell marker is tagged as "TFN") then selection.find
will not find the para/cell.

Is there any way to find "empty" paragraphs w/i tables using selection.find?

I can use:

Dim tblRng As Range
Dim tbl As Table
Dim para As Paragraph

For Each tbl In ActiveDocument.Tables
Set tblRng = tbl.Range
For Each para In tblRng.Paragraphs
If para.Style = "TFN" Then
para.Range.Select
MsgBox para.Style
End If
Next para
Next tbl

But this is rather more complicated than simply running a selection.find on
the "TFN" style. I'm trying to avoid having to hunt through several hundred
macros to replace all of our legacy code.

Thanks in advance!

Steve

--
Steven Lee
Vaporloop Technology Solutions

Re: How to find a paragraph style in a Wd 2003 table by Greg

Greg
Wed Mar 21 10:04:57 CDT 2007

Maybe something like:

Sub ScratchMacro()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Tables(1).Range
With oRng.Find
.Style = "TFN"
While .Execute
oRng.Cells(1).Select
oRng.Move wdCell, 1
If Selection.Range.End + 1 = ActiveDocument.Tables(1).Range.End
Then
Exit Sub
End If
Wend
End With
End Sub

On Mar 21, 10:39 am, Steven Lee <stevenl...@nospam.comcast.net> wrote:
> Hi,
>
> We have a legacy template (Word 2000) that uses paragraph styles in tables
> (as that was the only way you could have table styles in 2000.). We also
> have code that processes documents and looks for styles. In this case the
> style is TFN (Table Footnote). If there is text w/i the cell tagged as TFN
> then Selection.Find.Style = "TFN" will find the cell. However, if the celll
> is empty (but the end of cell marker is tagged as "TFN") then selection.find
> will not find the para/cell.
>
> Is there any way to find "empty" paragraphs w/i tables using selection.find?
>
> I can use:
>
> Dim tblRng As Range
> Dim tbl As Table
> Dim para As Paragraph
>
> For Each tbl In ActiveDocument.Tables
> Set tblRng = tbl.Range
> For Each para In tblRng.Paragraphs
> If para.Style = "TFN" Then
> para.Range.Select
> MsgBox para.Style
> End If
> Next para
> Next tbl
>
> But this is rather more complicated than simply running a selection.find on
> the "TFN" style. I'm trying to avoid having to hunt through several hundred
> macros to replace all of our legacy code.
>
> Thanks in advance!
>
> Steve
>
> --
> Steven Lee
> Vaporloop Technology Solutions



Re: How to find a paragraph style in a Wd 2003 table by stevenlmas

stevenlmas
Wed Mar 21 10:20:53 CDT 2007

Thanks for the effort Greg. Unfortuantely your suggestion doesn't find the
empty cell I'm looking for, so it ends up selecting the first cell in the
table.


--
Steven Lee
Vaporloop Technology Solutions


"Greg Maxey" wrote:

> Maybe something like:
>
> Sub ScratchMacro()
> Dim oRng As Word.Range
> Set oRng = ActiveDocument.Tables(1).Range
> With oRng.Find
> .Style = "TFN"
> While .Execute
> oRng.Cells(1).Select
> oRng.Move wdCell, 1
> If Selection.Range.End + 1 = ActiveDocument.Tables(1).Range.End
> Then
> Exit Sub
> End If
> Wend
> End With
> End Sub
>
> On Mar 21, 10:39 am, Steven Lee <stevenl...@nospam.comcast.net> wrote:
> > Hi,
> >
> > We have a legacy template (Word 2000) that uses paragraph styles in tables
> > (as that was the only way you could have table styles in 2000.). We also
> > have code that processes documents and looks for styles. In this case the
> > style is TFN (Table Footnote). If there is text w/i the cell tagged as TFN
> > then Selection.Find.Style = "TFN" will find the cell. However, if the celll
> > is empty (but the end of cell marker is tagged as "TFN") then selection.find
> > will not find the para/cell.
> >
> > Is there any way to find "empty" paragraphs w/i tables using selection.find?
> >
> > I can use:
> >
> > Dim tblRng As Range
> > Dim tbl As Table
> > Dim para As Paragraph
> >
> > For Each tbl In ActiveDocument.Tables
> > Set tblRng = tbl.Range
> > For Each para In tblRng.Paragraphs
> > If para.Style = "TFN" Then
> > para.Range.Select
> > MsgBox para.Style
> > End If
> > Next para
> > Next tbl
> >
> > But this is rather more complicated than simply running a selection.find on
> > the "TFN" style. I'm trying to avoid having to hunt through several hundred
> > macros to replace all of our legacy code.
> >
> > Thanks in advance!
> >
> > Steve
> >
> > --
> > Steven Lee
> > Vaporloop Technology Solutions
>
>
>

Re: How to find a paragraph style in a Wd 2003 table by Greg

Greg
Wed Mar 21 10:42:37 CDT 2007

Steven,

Yes I see what you mean. When I ran that snipet of code I have some
cells with TFN and text and some with just TFN.

Actually in a table with a single TFN formatted empty cell the style
is found. .Found returns true, but the range is not redefined to the
empty cell. I don't have a solution.


On Mar 21, 11:20 am, Steven Lee <stevenl...@nospam.comcast.net> wrote:
> Thanks for the effort Greg. Unfortuantely your suggestion doesn't find the
> empty cell I'm looking for, so it ends up selecting the first cell in the
> table.
>
> --
> Steven Lee
> Vaporloop Technology Solutions
>
>
>
> "Greg Maxey" wrote:
> > Maybe something like:
>
> > Sub ScratchMacro()
> > Dim oRng As Word.Range
> > Set oRng = ActiveDocument.Tables(1).Range
> > With oRng.Find
> > .Style = "TFN"
> > While .Execute
> > oRng.Cells(1).Select
> > oRng.Move wdCell, 1
> > If Selection.Range.End + 1 = ActiveDocument.Tables(1).Range.End
> > Then
> > Exit Sub
> > End If
> > Wend
> > End With
> > End Sub
>
> > On Mar 21, 10:39 am, Steven Lee <stevenl...@nospam.comcast.net> wrote:
> > > Hi,
>
> > > We have a legacy template (Word 2000) that uses paragraph styles in tables
> > > (as that was the only way you could have table styles in 2000.). We also
> > > have code that processes documents and looks for styles. In this case the
> > > style is TFN (Table Footnote). If there is text w/i the cell tagged as TFN
> > > then Selection.Find.Style = "TFN" will find the cell. However, if the celll
> > > is empty (but the end of cell marker is tagged as "TFN") then selection.find
> > > will not find the para/cell.
>
> > > Is there any way to find "empty" paragraphs w/i tables using selection.find?
>
> > > I can use:
>
> > > Dim tblRng As Range
> > > Dim tbl As Table
> > > Dim para As Paragraph
>
> > > For Each tbl In ActiveDocument.Tables
> > > Set tblRng = tbl.Range
> > > For Each para In tblRng.Paragraphs
> > > If para.Style = "TFN" Then
> > > para.Range.Select
> > > MsgBox para.Style
> > > End If
> > > Next para
> > > Next tbl
>
> > > But this is rather more complicated than simply running a selection.find on
> > > the "TFN" style. I'm trying to avoid having to hunt through several hundred
> > > macros to replace all of our legacy code.
>
> > > Thanks in advance!
>
> > > Steve
>
> > > --
> > > Steven Lee
> > > Vaporloop Technology Solutions- Hide quoted text -
>
> - Show quoted text -



Re: How to find a paragraph style in a Wd 2003 table by stevenlmas

stevenlmas
Wed Mar 21 10:55:50 CDT 2007

Thanks for looking at this, Greg. I can't wait until we try to port this to
office 2007!

Best,
Steve
--
Steven Lee
Vaporloop Technology Solutions


"Greg Maxey" wrote:

> Steven,
>
> Yes I see what you mean. When I ran that snipet of code I have some
> cells with TFN and text and some with just TFN.
>
> Actually in a table with a single TFN formatted empty cell the style
> is found. .Found returns true, but the range is not redefined to the
> empty cell. I don't have a solution.
>
>
> On Mar 21, 11:20 am, Steven Lee <stevenl...@nospam.comcast.net> wrote:
> > Thanks for the effort Greg. Unfortuantely your suggestion doesn't find the
> > empty cell I'm looking for, so it ends up selecting the first cell in the
> > table.
> >
> > --
> > Steven Lee
> > Vaporloop Technology Solutions
> >
> >
> >
> > "Greg Maxey" wrote:
> > > Maybe something like:
> >
> > > Sub ScratchMacro()
> > > Dim oRng As Word.Range
> > > Set oRng = ActiveDocument.Tables(1).Range
> > > With oRng.Find
> > > .Style = "TFN"
> > > While .Execute
> > > oRng.Cells(1).Select
> > > oRng.Move wdCell, 1
> > > If Selection.Range.End + 1 = ActiveDocument.Tables(1).Range.End
> > > Then
> > > Exit Sub
> > > End If
> > > Wend
> > > End With
> > > End Sub
> >
> > > On Mar 21, 10:39 am, Steven Lee <stevenl...@nospam.comcast.net> wrote:
> > > > Hi,
> >
> > > > We have a legacy template (Word 2000) that uses paragraph styles in tables
> > > > (as that was the only way you could have table styles in 2000.). We also
> > > > have code that processes documents and looks for styles. In this case the
> > > > style is TFN (Table Footnote). If there is text w/i the cell tagged as TFN
> > > > then Selection.Find.Style = "TFN" will find the cell. However, if the celll
> > > > is empty (but the end of cell marker is tagged as "TFN") then selection.find
> > > > will not find the para/cell.
> >
> > > > Is there any way to find "empty" paragraphs w/i tables using selection.find?
> >
> > > > I can use:
> >
> > > > Dim tblRng As Range
> > > > Dim tbl As Table
> > > > Dim para As Paragraph
> >
> > > > For Each tbl In ActiveDocument.Tables
> > > > Set tblRng = tbl.Range
> > > > For Each para In tblRng.Paragraphs
> > > > If para.Style = "TFN" Then
> > > > para.Range.Select
> > > > MsgBox para.Style
> > > > End If
> > > > Next para
> > > > Next tbl
> >
> > > > But this is rather more complicated than simply running a selection.find on
> > > > the "TFN" style. I'm trying to avoid having to hunt through several hundred
> > > > macros to replace all of our legacy code.
> >
> > > > Thanks in advance!
> >
> > > > Steve
> >
> > > > --
> > > > Steven Lee
> > > > Vaporloop Technology Solutions- Hide quoted text -
> >
> > - Show quoted text -
>
>
>