| View previous topic :: View next topic |
| Author |
Message |
LtlBear General User

Joined: 03 Feb 2008 Posts: 5
|
Posted: Sat Jul 12, 2008 8:01 pm Post subject: Text Cursor in Writer - Find if Number Format |
|
|
Hi all,
I have a Macro that uses the text cursor to go through a word document looking for Paragraph Marks and does some work if it finds one. However, I want it to not run if what follows is text that is in a bullet or number format. I can't figure out how to determine this, though. Anyone provide some help?
Dim objDoc as object
Dim oVC as object
objDoc = ThisComponent
oVC = objDoc.CurrentController().getViewCursor()
Do While oVC.goRight(1,true)
If Asc(oVC.String) = 13 Then ' Need code to decide if what follows is number format
' Do Something
End If
Loop
When I step through my code and check the writer document, the .goRight selects the Paragraph Mark and the following number. However, oVC.CharStyleName and oVC.ParaStyleName are blank. _________________ -Bear |
|
| Back to top |
|
 |
JohnV Administrator

Joined: 07 Mar 2003 Posts: 8982 Location: Lexinton, Kentucky, USA
|
Posted: Sun Jul 13, 2008 8:09 am Post subject: |
|
|
The are various ways of numbering paragraphs but I think you are interested in those created with the numbering or bullet icons.
A Text Cursor knows how to "gotoNextParagraph" so I have used one instead of the View Cursor. | Code: | Sub Main
Dim objDoc as object
Dim oTC as object,iAns
objDoc = ThisComponent
oTC = objDoc.Text.createTextCursor 'Created at beginning by default.
N=0
Do
N=N+1
If isNumeric(oTC.NumberingStyleName) then
iAns = MsgBox ("Paragraph #" & N & " appears to be numbered or bulleted using the icons."_
& Chr(13) & "The NumberingStyleName = " & oTC.NumberingStyleName,1)
If iAns = 2 then End
Endif
Loop While oTC.gotoNextParagraph(false)
End Sub |
|
|
| Back to top |
|
 |
LtlBear General User

Joined: 03 Feb 2008 Posts: 5
|
Posted: Sun Jul 13, 2008 7:24 pm Post subject: |
|
|
Thanks. The Text Cursor Object worked for me. I had to rethink my code, but was able to make it work with that object over the View Cursor Object. _________________ -Bear |
|
| Back to top |
|
 |
|