Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Office Automation and Text Boxes
Message
De
20/08/2003 11:56:04
 
 
À
20/08/2003 11:36:35
Gary Taylor
East St. Information Systems
Essex Junction, Vermont, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00821827
Message ID:
00821833
Vues:
21
>I am using VFP 6.0 to open and control a Word document. I am able to search and replace in the main document, but I cannot s & p within the 43 or so Text Boxes within the document. How can I select (either each one or all) text boxes for the search and replace function?

Gary,

I just tested this with one textbox and it works over here
eg =SearchAndReplace_Word(obj, 'abcde','qwerty', .f., .f.)
*!*	With Options
*!*	        .CheckSpellingAsYouType = False
*!*	        .CheckGrammarAsYouType = True
*!*	        .SuggestSpellingCorrections = True
*!*	        .SuggestFromMainDictionaryOnly = False
*!*	        .CheckGrammarWithSpelling = True
*!*	        .ShowReadabilityStatistics = False
*!*	        .IgnoreUppercase = True
*!*	        .IgnoreMixedDigits = True
*!*	        .IgnoreInternetAndFileAddresses = True
*!*	        .AllowCombinedAuxiliaryForms = True
*!*	        .EnableMisusedWordsDictionary = True
*!*	        .AllowCompoundNounProcessing = True
*!*	        .UseGermanSpellingReform = True
*!*	    End With
function SearchAndReplace_Word
	lparameters	WordObj, SearchFor, ReplaceWith, MatchCase, MatchWholeWord, ;
				MatchWildCards, MatchSoundsLike, MatchAllWordForms, FormatInfoAlso

	#define wdFindStop     0
	#define wdFindContinue 1
	#define wdFindAsk      2

	#define wdReplaceNone  0
	#define wdReplaceOne   1
	#define wdReplaceAll   2

	for each StoryRange in WordObj.ActiveDocument.StoryRanges
		with StoryRange
			.WholeStory
			.Find.ClearFormatting
			.Find.Replacement.ClearFormatting
		
		
			local Forward, Wrap 
			Forward = TRUE
			Wrap = wdFindContinue
			
			&& replacement max 254 chars
			do case
			case len(ReplaceWith) <= 254
				=StoryRange.Find.Execute(SearchFor, MatchCase, MatchWholeWord, MatchWildCards, MatchSoundsLike, MatchAllWordForms, Forward, Wrap, FormatInfoAlso, ReplaceWith, wdReplaceAll, , , , )
			otherwise
				local x, xReplace, ReplaceLeft
				ReplaceLeft = ReplaceWith
				
				do while !empty(len(ReplaceLeft) )
					do case
					case len(ReplaceLeft) < 255
						xReplace = ReplaceLeft
						ReplaceLeft = ''
					otherwise
						xReplace = left(ReplaceLeft, 254 - len(SearchFor)) + SearchFor
						ReplaceLeft = Substr(ReplaceLeft, 254 - len(SearchFor) + 1)
					endcase
					
					=StoryRange.Find.Execute(SearchFor, MatchCase, MatchWholeWord, MatchWildCards, MatchSoundsLike, MatchAllWordForms, Forward, Wrap, FormatInfoAlso, xReplace, wdReplaceAll, , , , )
			
				enddo
			endcase
		endwith
	endfor
	#undefine wdFindStop
	#undefine wdFindContinue
	#undefine wdFindAsk

	#undefine wdReplaceNone
	#undefine wdReplaceOne
	#undefine wdReplaceAll
endfunc
*--------------------------------------------------------------------------
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform