how can i use .find to locate a bullet style property?

I

ian

I have used help to solve this but now i am stuck.
I want to be able to scan a large document which has
tables.
In some of the table's cells are paragraphs I want to
select. These paragraphs have a bullet at the start and
other various properties such as font etc.

I am only searching for the bulletted ones. hence not
bothered by fonts, bold, italics etc.

I went to help learnt to how make a style and edit it from
the format>style... menu.

but it still wont locate the paragraphs, just the one I
made the style from...
It seems to have changed the properties of the paragraph
when I gave it a style name.

I recorded my attempt and tried to edit it from VBA but
just asking to search the style with

Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles("ABullet")
Selection.Find.ParagraphFormat.Borders.Shadow = False
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
and further removed all in the with..end with but no luck.

Once again im just trying to locate bullet paragraphs from
VBA hope you can help.
Ian
 
H

Helmut Weber

Hi Ian,
some more information on listparagraphs:
aLpg = ActiveDocument.ListParagraphs.Count
returns the number of listparagraphs in a doc.
ActiveDocument.ListParagraphs.Item(aLpg).Range.Select
selects the listparagraph(aLpg).
Greetings from Bavaria, Germany
Helmut Weber
"red.sys" & chr$(64) & "t-online.de"
Word 97, XP, NT4.0, W98
 
I

Ian

thanks Helmut this works...

If Selection.Range.ListFormat.ListType = 0 Then _
MsgBox "No Bullet" Else MsgBox "Bulleted"
Selection.MoveDown Unit:=wdParagraph, Count:=1
*but now, this problem...

when i MoveDown in the table it goes to the cell
on the right then off the table row, before the next lower
cell.

how do i sellect the cell and movedown or movedown a cell?
i've tried Selection.MoveDown unit=wdcell, but it didn't
move???
i've tried
Selection.SelectCell
Selection.MoveDown
but whilst works sometimes jumps cells other times???
usually jumps the cell i'm after
(a large table cell with several bulleted paragraphs)
BUT only/usually on the first run???How unpredictable??

When i get the code working it will run a basic
form that will .find a title eg"WMS3.4" in a table
move down 4 cells to the bulleted paragraphs and
place them in a list box for selection.
I've got the form running with list boxes
I've got the .find working for the title
As the tables are two columns and info is in both sides
eg.

________________________
| WMS2.4 | WMS3.4 |
------------------------
|..........|...........|
|..........|...........|
|..........|...........|
_______________________
| bulleted | bulleted |
|paragraphs|paragraphs |
------------------------
I need to move down under WMS3.4?
some of the other cells have paragraphs in them.

I'm only want to "move down 4 cells to the bulleted
paragraphs"

Hope you can help, and that it is not too busy for you.
Thanks again Ian
PS just thought might try count=3???But simple code may be
better?
 
H

Helmut Weber

Hi Ian,
some routines from a project on processing of word tables:
Public Function WhatTable() As Integer
Dim r As Range
Set r = Selection.Range
r.Start = 0
r.End = Selection.Start
WhatTable = r.Tables.count
End Function
Public Function WhatColumn() As Integer
WhatColumn = Selection.Information
(wdEndOfRangeColumnNumber)
End Function
Public Function WhatRow() As Integer
WhatColumn = Selection.Information
(wdEndOfRangeRowNumber)
End Function
Sub SelectCell(tx%, rx%, cx%)
ActiveDocument.Tables(tx).Cell(rx, cx).Select
End Sub
Public Sub GotoEndofCell(tx%, rx%, cx%)
SelectCell tx, rx, cx
Selection.EndKey
End Sub
Public Sub GotoStartofCell(tx%, rx%, cx%)
SelectCell tx, rx, cx
Selection.HomeKey
End Sub
I would suggest something like:
r = whatrow
SelectCell 1, r + 4, c
Typing errors possible.
Some conditions still to be set,
like selection.collapse, extendmode = false etc.
Greetings from Bavaria, Germany
Helmut Weber
"red.sys" & chr$(64) & "t-online.de"
Word 97, NT4.0
 
B

Bruce Brown

Ian & Helmut

Finding text in a table is problematic because find works horizontally
by rows, not up and down in columns. Instead of hunting for phrases
and bullets, it might be easier to let them come to you, so to speak,
by vertically testing each cell in a column for the presence of
bullets and WMS phrases.

That's the idea behind this code, which you might want to try in
addition to Helmut's. It stops at the first occurrence of bullets in
the same column below the WMS phrase, whether the bullets are styles
or symbols.

Dim T As Table, Col As Column, C As Cell
Dim R As Range, WMSFound As Boolean, WMSColumn As Byte
Application.ScreenUpdating = False
For Each T In ActiveDocument.Tables
For Each Col In T.Columns
For Each C In Col.Cells
If InStr(C.Range.Words(1).Text, "WMS") > 0 Then
Application.ScreenUpdating = True
C.Range.Select
Application.ScreenRefresh
MsgBox "WMS here"
Application.ScreenUpdating = False
WMSFound = True
WMSColumn = Col.Index
End If
If WMSColumn = Col.Index And WMSFound And _
(C.Range.ListFormat.ListType = 2 _
Or Asc(C.Range.Characters(1)) = 149) Then
Set R = C.Range.Duplicate
R.End = R.End - 1
Application.ScreenUpdating = True
R.Select
Application.ScreenRefresh
MsgBox "Bullets here"
'Do your thing with the bulleted paras here <-----
Selection.Collapse wdCollapseEnd
Application.ScreenUpdating = False
WMSFound = False
End If
Next
Next
Next

Hope this is something like what you're looking for. - Bruce
 

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