OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Text Cursor in Writer - Find if Number Format

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
LtlBear
General User
General User


Joined: 03 Feb 2008
Posts: 5

PostPosted: Sat Jul 12, 2008 8:01 pm    Post subject: Text Cursor in Writer - Find if Number Format Reply with quote

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
View user's profile Send private message
JohnV
Administrator
Administrator


Joined: 07 Mar 2003
Posts: 9183
Location: Lexinton, Kentucky, USA

PostPosted: Sun Jul 13, 2008 8:09 am    Post subject: Reply with quote

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
View user's profile Send private message
LtlBear
General User
General User


Joined: 03 Feb 2008
Posts: 5

PostPosted: Sun Jul 13, 2008 7:24 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group