Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can I Find text and delete row in a word document

Status
Not open for further replies.

dotnik

Programmer
Nov 14, 2003
24
IT
Hi,

I'm Nicola and live in Italy, near Matera.
I have two question for you:
1. find text selection
2. delete table's row

I must delete row because I want to reduce empty spaces in the document.

Thanks.

Best regard

Nicola
 
Hi Nicola,

First question - use Find which is a method of the Document. You can use it like this:
Code:
oWord = CREATEOBJECT("Word.Application")
oDoc = oWord.ActiveDocument
oDoc.Find.Execute([i][b]FindText, MatchCase, MatchWholeWord, MatchWildcards, MatchSoundsLike, MatchAllWordForms, Forward, Wrap, Format, ReplaceWith, Replace, MatchKashida, MatchDiacritics, MatchAlefHamza, MatchControl[/b][/i])

I think the parameter names make it clear what you need to pass.

Second question - use the delete method of the row object in the table:
Code:
oword = GETOBJECT(,'word.application')
oword.ActiveDocument.Tables(1).Rows(1).Delete

I've often used the Macro recorder in Word to get the syntax for this sort of thing by using. You will find this off the Tools menu. Once you have specified a name for the macro and set the recorder going, you carry out whatever steps you want to do and then stop the recording. Go back to Tools\Macro and view macros and you can then see what is needed. The macro is written in VBA but you should be able to translate it to VFP.

It is also very useful looking at the Object Model which shows you what Properties, Events & Methods are available. You get to this with Tools\Macro\Visual Basic editor and once the editor opens you take the menu option View\Object Browser (or press F2).

There are also lots of examples in the FAQs.

Hope that helps,

Stewart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top