FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Select part of the cell
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Select part of the cell
Posted: Sat Aug 19, 2023 12:38 PM
Hi,

I need to select a fragment in a table cell. I do this:
Code (fw): Select all Collapse
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 ?
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Select part of the cell
Posted: Sat Aug 19, 2023 05:52 PM
Dear Yuri,
Code (fw): Select all Collapse
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
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: Select part of the cell
Posted: Sat Aug 19, 2023 06:11 PM

Thank you, Antonio! I'll try

Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: Select part of the cell
Posted: Mon Aug 21, 2023 01:53 PM
I need to find all the spellings of the string. To do this
Code (fw): Select all Collapse
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?
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Select part of the cell
Posted: Mon Aug 21, 2023 02:52 PM

sorry, I have no idea

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Select part of the cell
Posted: Mon Aug 21, 2023 04:18 PM
Natter wrote:oRng.Find.MatchAllWordForms:=.T.[/code]
Try
Code (fw): Select all Collapse
oRng:Find:MatchAllWordForms := .T.
Note: colons instead of dots.

Continue the discussion