When we get the Word document pedigree (it is a pedigree for a Standardbred racehorse) we're trying to run through each pedigree and updating some of the information pertaining to the sale (hip number, location at the sale, owner's name).
This is new to me but I was able to use the Find/Replace code to update data in one of the cells of the table this way; orange = oword.activedocument.range(0,0) #define wdreplaceone 1 WITH orange.find .text = "Barn" .replacement.text = "North Hall" lfound = .execute( , , , , , , , , , , wdreplaceone ) endwith orange = oword.activedocument.range(0,0) WITH orange.find .text = "Row" .replacement.text = "Row A" lfound = .execute( , , , , , , , , , , wdreplaceone ) endwith But, the first cell of the first table in the Word document contains a number in sequence inserted by the group that is actually creating the document. The first cell will eventually contain the hip number assigned to that particular horse which is being sold at auction. I'm starting to think that the easiest solution would be for me to ask them to just insert a placeholder like "hipnumb" that the code could look for in a Find/Replace situation. Jim Harvey Spring Grove, PA cell 717-887-2565 -----Original Message----- From: ProFox [mailto:profox-boun...@leafe.com] On Behalf Of Richard Kaye Sent: Tuesday, April 08, 2014 7:37 AM To: profox@leafe.com Subject: RE: Word automation 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:profoxtech-boun...@leafe.com] On Behalf Of Jim Harvey Sent: Monday, April 07, 2014 6:19 PM To: profoxt...@leafe.com 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 [excessive quoting removed by server] _______________________________________________ Post Messages to: ProFox@leafe.com 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/000301cf5327$4273d0b0$c75b7210$@harv...@verizon.net ** 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.