>Hi everyone:
>I'm trying to automate entry into a table in Word using a VFP project. I have no problem entering values into the correct cell in a table, but entering a symbol is giving me an error. I can either enter the symbol at the beginning of a range (in which the range is the word document), or if i try to be more specific, i get the following error:
>
> "ole dispatch exception code 0 from Microsoft Word: This method or property is not available because the object does not refer to simple range or selection..."
>
>BTW, i am using MS word 97. What i want to do is insert a symbol (an arrow pointing upwards) in a specific cell in a table. here is the code that puts the arrow at the beginning of the page:
>
> oRange.insertsymbol(-3923,"symbol",.t.)
>
>Remember, oRange is the entire document.
>
>When I try to put it into a table (namely oTable)), my code is as follows:
>
> oTable.Cell[2,6].range.insertsymbol(-3921,"symbol",.t.)
>
>I get the above error message when I use this code. Does anyone have any advice? BTW, I have found the book MS office Automation with Visual Foxpro to be a very handy reference for my coding. Unfortunately, it doesn't have an answer to this specific problem. Any suggestion would be greatly appreciated.
>
>TIA,
>
>Paul
Paul,
Use selection and collapse before inserting. ie:
#DEFINE wdCollapseStart 1
#DEFINE wdCollapseEnd 0
oWord = CreateObject('Word.Application')
With oWord
.Documents.Add
oTable = .ActiveDocument.tables.add(.ActiveDocument.Content,3,8)
oTable.Cell(1,3).Select
.Selection.Collapse(wdCollapseStart)
.Selection.InsertSymbol(9675,'',.t. )
.Selection.TypeText(' Yes'+Chr(13))
.Selection.InsertSymbol(9675,'',.t. )
.Selection.TypeText(' No'+Chr(13))
.Selection.InsertSymbol(9675,'',.t. )
.Selection.TypeText(' Maybe')
oTable.Cell(2,6).Select
.Selection.Collapse(wdCollapseStart)
.Selection.InsertSymbol(-3921,"symbol",.t.)
oTable.Cell(1,1).Select
.Selection.Collapse(wdCollapseStart)
.Visible = .t.
.Activate
endwith
PS: This would do too:
oRange = oTable.Cell(2,6).Range
oRange.Collapse(wdCollapseStart)
oRange.InsertSymbol(-3921,"symbol",.t.)
Cetin