List Type and paragraph command? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

List Type and paragraph command?

DorisTanDorisTan Posts: 12Member
Hi;
i am using VB6 to read each paragraph and word from microsoft word, can any one here tell me how to distinguish the type of list number? eg:

in my document, i have:

1. something for type 1, 2, 3
a. something for type a, b, c
i. somethign for type i, ii, iii
b. some other thing for type a, b, c
2. some other thing for type 1, 2, 3

in my program, how can i know whether it is 1, 2, 3? or a, b, c? or i, ii, iii?

besides, may i know how can i know he starting and ending of a paragraph? example:

This is my New paragraph

is there any command that can tells the starting word of this paragraph is "This" and the ending is "paragraph" ?

Really need your help here, Thank you very much


Comments

  • dokken2dokken2 Posts: 532Member
    Fairly easy to determine the paragraphs and list paragraphs in a word document. Add the code to 3 buttons. However, I haven't been able to figure out how to get to the list item number.



    [code]
    'AUTOMATE WORD
    Dim WordApp As Word.Application


    Private Sub Command1_Click()
    'NEW WORD APP
    Set WordApp = New Word.Application
    WordApp.Visible = True
    'OPEN DOCUMENT
    WordApp.Documents.Open "c:MYWORD.DOC"
    End Sub

    Private Sub Command2_Click()
    'NUMBER PARAGRAPHS
    MsgBox "Number paragraphs=" & WordApp.ActiveDocument.Paragraphs.Count

    'SHOW EACH PARAGRAPH
    Dim para As Paragraph
    For Each para In WordApp.ActiveDocument.Paragraphs
    MsgBox para
    Next para

    'SHOW PARAGRAPH LIST ITEMS
    Dim i As Integer
    MsgBox "==SHOW LIST PARAGRAPHS=="
    For i = 1 To WordApp.ActiveDocument.ListParagraphs.Count
    MsgBox WordApp.ActiveDocument.ListParagraphs.Item(i).Range.Text
    Next
    End Sub

    Private Sub Command3_Click()
    'CLOSE DOCUMENT AND QUIT WORD
    WordApp.Documents.Close
    WordApp.Quit
    Set WordApp = Nothing
    End Sub
    [/code]
  • dokken2dokken2 Posts: 532Member
    Use this code to determine the paragraph list level:

    [code]
    'SHOW PARAGRAPH LIST ITEMS
    Dim i As Integer
    Dim level As Integer
    MsgBox "==SHOW LIST PARAGRAPHS=="
    For i = 1 To WordApp.ActiveDocument.ListParagraphs.Count
    level = WordApp.ActiveDocument.ListParagraphs.Item(i).Range.ListFormat.ListLevelNumber
    MsgBox WordApp.ActiveDocument.ListParagraphs.Item(i).Range.Text, , "List Level=" & level
    Next
    [/code]
  • DorisTanDorisTan Posts: 12Member
    Thank you very much, but if i would like to know the type of the level? Eg;
    If (type likes 'i') then
    msgbox "This is type i, ii, iii..."
    else (type like 'a') then
    msgbox "This is type a, b, c...."
    ....
    end if

    i know the code that you provided can extract the number of each paragraph, but what i want is to know the type name of it. Hope someone can help me, thank you :)
  • dokken2dokken2 Posts: 532Member
    [code]
    'SHOW PARAGRAPH LIST ITEMS
    Dim i As Integer
    MsgBox "==SHOW LIST STRING/ITEM#=="
    For i = 1 To WordApp.ActiveDocument.ListParagraphs.Count
    MsgBox WordApp.ActiveDocument.ListParagraphs.Item(i).Range.ListFormat.ListString
    Next
    [/code]



    : Thank you very much, but if i would like to know the type of the level? Eg;
    : If (type likes 'i') then
    : msgbox "This is type i, ii, iii..."
    : else (type like 'a') then
    : msgbox "This is type a, b, c...."
    : ....
    : end if
    :
    : i know the code that you provided can extract the number of each paragraph, but what i want is to know the type name of it. Hope someone can help me, thank you :)
    :

  • DorisTanDorisTan Posts: 12Member
    Thanks Friend, i am really sorry cause its still not what i want, and sorry if i misunderstood you.
    From my research i found that there is a function called "numberStyle" that return something like wdListNumberStyleLowercaseRoman ... but i am not really clear with the usage of this function. I want to know for each paragraph if the numberstyle is i, ii, then do something, else if it is style a, b, c, ... i do some other thing... can anyone help me? really need your help, thanks

    : [code]
    : 'SHOW PARAGRAPH LIST ITEMS
    : Dim i As Integer
    : MsgBox "==SHOW LIST STRING/ITEM#=="
    : For i = 1 To WordApp.ActiveDocument.ListParagraphs.Count
    : MsgBox WordApp.ActiveDocument.ListParagraphs.Item(i).Range.ListFormat.ListString
    : Next
    : [/code]
    :

  • descent_33descent_33 Posts: 8Member
    what is this
  • DorisTanDorisTan Posts: 12Member
    here is more explaination:
    If you try on the code below, you may have a lists of numberStyle displayed.

    Dim i As Integer
    For i = 1 To 9
    MsgBox WordApp.ActiveDocument.ListTemplates(1).ListLevels(i).NumberStyle
    Next

    when you write a '=' behind the Numberstyle, you will found that there is a list of Style choises, like wdListNumberStyleAiueo, wdListNumberStyleAiueoHalfWidth, ... this is the thing that i want, but i just dont know how to apply it to my code, cause this will display out all the NumberStyle used in my document, what i want is to list the Style for each paragraph. Eg;

    Dim parCounter As Word.Paragraph
    Set WordObj = CreateObject("Word.Application")
    Set WordDoc = WordObj.Documents.Open("c: est.doc")
    Set wParas = WordDoc.Paragraphs

    For Each parCounter In wParas
    ' here is the problem, how can i compare each paragraph's NumberStyle here?
    next

    Hope someone can help me or even provide me a website for study, thank you :)
Sign In or Register to comment.