AnsweredAssumed Answered

Setting CurrentParagraph with word wrap not working

Question asked by Layne Fowler on Sep 7, 2018
Latest reply on Sep 25, 2018 by Layne Fowler

It seems that setting the CurrentParagraph property actually sets the current line, not paragraph, when applied to a note with word wrap.


Simple code to demonstrate:


Dim swApp As Object
Dim swModel As Object
Dim swSelMgr As SldWorks.SelectionMgr
Dim swAnnObj As Object
Dim swAnn As SldWorks.Annotation
Dim swParagraphs As SldWorks.Paragraphs
Dim nParagraphs As Long
Dim iParagraphs As Long
Dim bRet As Boolean
Dim sRet As String

Sub main()
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swSelMgr = swModel.SelectionManager
    Set swAnnObj = swSelMgr.GetSelectedObject6(1, -1)
    Set swAnn = swAnnObj.GetAnnotation
    Set swParagraphs = swAnn.GetParagraphs
    nParagraphs = swParagraphs.Count
    For iParagraphs = 0 To nParagraphs - 1
        swParagraphs.CurrentParagraph = iParagraphs
        sRet = swParagraphs.GetText(True)
        bRet = swParagraphs.SetBulletsAndNumbering(1, 0, 1, 1, 1)
        bRet = swParagraphs.UpdateParagraph()
End Sub


This will number each line in a selected note. If you stretch the width of the note so there is no word wrapping this snippet will work fine. If you narrow the width of the note so that lines begin to wrap this macro behaves incorrectly.


It looks like Count counts the true number of paragraphs while CurrentParagraph sets the line number. However, if you try to manually set the line number greater than the total number of paragraphs, that does not work either.


Am I correct in concluding this API property is broken or am I missing something here?