How to underline subset of Note?

Hi,

   I am trying to underline the particular text from selected Note by using the following code

//======================================================//

CComPtr pSWModel;
m_pSwApp->get_IActiveDoc2(&pSWModel); 

CComPtr pSWSelectionMgr;
pSWModel->get_ISelectionManager(&pSWSelectionMgr);

CComPtr pSelectedEntity = NULL;
pSWSelectionMgr->GetSelectedObject6(1, -1, &pSelectedEntity);

CComQIPtr pNote(pSelectedEntity);
CComBSTR text;
pNote->GetText(&text);

long txtCount;
pNote->GetTextCount(&txtCount);

CComPtr pAnnotation;
pNote->IGetAnnotation(&pAnnotation);

long txtFormatCount;
pAnnotation->GetTextFormatCount(&txtFormatCount);

CComPtr txtFormat;
pAnnotation->IGetTextFormat(0, &txtFormat);

txtFormat->put_Underline(VARIANT_TRUE);
VARIANT_BOOL retVal;
pAnnotation->ISetTextFormat(0, FALSE, txtFormat, &retVal);

//======================================================//

Here, my txtCount is 5 and txtFormatCount is 1. If I use the pAnnotation->ISetTextFormat() method then it underlined all text but I want to underline the first line text only.

I have tried changing the index (i.e. 0 in the above code) but it underlined all the text for each index. Is anyone know How should I underlined that particular text?

Thanks and Regards,

Mahadev

SolidworksApi/macros