Select part of the cell

Select part of the cell

Postby Natter » Sat Aug 19, 2023 12:38 pm

Hi,

I need to select a fragment in a table cell. I do this:
Code: Select all  Expand view  RUN
oTb := oWord:ActiveDocument:Tables
oRng:=oTb:Item(1):Cell(x,y):Range
oRng:Select()
oWrd:Selection:Find:Execute('Keyword') //keyword for getting coordinates
dim:={{oTb:Item(cnt):Cell(st,3):Start,oWrd:Selection:Start-1}, ;
          {oWrd:Selection:End+1, oTb:Item(cnt):Cell(xt,y):End}} //coordinates of 2 sections of the cell

oRng:=&oObj:Range(dim[1,1], mrg[1,2]) //next I try to select one or another part of the cell
oRng:Select()


However, the entire cell is selected. What am I doing wrong. What am I doing wrong ?
Natter
 
Posts: 1222
Joined: Mon May 14, 2007 9:49 am

Re: Select part of the cell

Postby Antonio Linares » Sat Aug 19, 2023 5:52 pm

Dear Yuri,

Code: Select all  Expand view  RUN
oTb := oWord:ActiveDocument:Tables
oCell := oTb:Item(1):Cell(x, y)

oStartRange := oCell:Range:Duplicate()
oEndRange := oCell:Range:Duplicate()

oStartRange:MoveStart(5, -1) // MoveStart to character, 5 represents wdCharacter
oEndRange:MoveEnd(5, 1)     // MoveEnd to character

oStartRangeText := oStartRange:Text
oEndRangeText := oEndRange:Text

oStartRange:Release()
oEndRange:Release()

; Now you can work with oStartRangeText and oEndRangeText as separate fragments
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42117
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Select part of the cell

Postby Natter » Sat Aug 19, 2023 6:11 pm

Thank you, Antonio! I'll try
Natter
 
Posts: 1222
Joined: Mon May 14, 2007 9:49 am

Re: Select part of the cell

Postby Natter » Mon Aug 21, 2023 1:53 pm

I need to find all the spellings of the string. To do this
Code: Select all  Expand view  RUN
oRng:=oTb:Item(1):Cell(x,y):Range:Duplicate()
[b]oRng.Find.MatchAllWordForms:=.T.[/b]
oRng:Find:Execute("MyText")


However, I get an error:
Word.Application:ACTIVEDOCUMENT:TABLES:ITEM:CELL:RANGE:DUPLICATE:FIND/3 DISP_E_MEMBERNOTFOUND: EXECUTE

If oRng.Find.MatchAllWordForms:=.F., then everything is fine. Why?
Natter
 
Posts: 1222
Joined: Mon May 14, 2007 9:49 am

Re: Select part of the cell

Postby Antonio Linares » Mon Aug 21, 2023 2:52 pm

sorry, I have no idea
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42117
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Select part of the cell

Postby Enrico Maria Giordano » Mon Aug 21, 2023 4:18 pm

Natter wrote:oRng.Find.MatchAllWordForms:=.T.[/code]


Try

Code: Select all  Expand view  RUN
oRng:Find:MatchAllWordForms := .T.


Note: colons instead of dots.
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 75 guests