I believe replacetext is for use by the Find object which is a probable cause 
for the error you're getting. You can use wildcards with the Find object, if 
that helps. In theory if the range references the cell, you could do something 
like this (untested pseudo-code warning!):

m.loRange=m.loWord.ActiveDocument. tables[1].RANGE()
WITH m.loRange
        .Find.MatchWildcards=.t.
        .Find.execute([*],,,.T.,,,.T.,1,,[newtext],2)
ENDIWTH

I use code similar to this for replacing text in a document. Check the docs for 
what each of those parameters represents in the Find object. If I can find a 
little time today I'll see if I can come up with a snippet that is not untested 
pseudo-code...

--
rk

-----Original Message-----
From: ProfoxTech [mailto:[email protected]] On Behalf Of Jim Harvey
Sent: Monday, April 07, 2014 6:19 PM
To: [email protected]
Subject: Word automation

Trying to figure out how to replace text in a cell in a table in a Word 
document.

        otable1 = oword.activedocument.tables[1]
        
        WITH otable1
        .cell[1,1].range.insertbefore("newtest")
        .cell[1,1].range.insertafter("newtest")
        endwith

This will add the text to the front and back of what's already there, but what 
I'd really like to do is replace the text in that cell...

I tried ".cell[1,1].range.replacetext("newtest")", and other variations, but 
get an error message.

The Find and replace won't work here because the text in that cell isn't 
consistant.

Jim Harvey
Spring Grove, PA
cell 717-887-2565


_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/DF1EEF11E586A64FB54A97F22A8BD04422A73C3FA0@ACKBWDDQH1.artfact.local
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to