Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
String Too Long to Fit
Message
From
19/05/2000 17:36:09
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
13/05/2000 14:20:50
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00369164
Message ID:
00371408
Views:
17
>Hi Cetin
>
>Thanks for your help again.
>
>My data SELECTS OK, it's selected prior to creating the Word object. Just FYI I have several programs similar to this for different clients and several for this client; they have all been working. I just started have problems with this one. But I would be anxious to adopt a better method.
>
>The ".Range.Find.Execute("<<"DATE">>",,,,,,,,,NewText,wdReplaceAll)"
>statement looks like it would be the answer to my problem. Probably execute faster than my old macro too. I would really appreciate it if you could help me get this to work.
>
>I've attempted to research that statement in my "Word 97 Macro and VBA" book and my "Using Visual FoxPro 6" book and can't find it. When using it in the following routine I get a message that "wdReplaceAll not found". Also how do I replace "TxtToReplace" with the contents of NewText since all but the date or some other variable changes for each letter?
>
>Below is a snippet of the routine where I would use the Range.Find.Execute......
>statement. I've noticed that my code is not accuratly reproduced here:
>the data I'm replacing such as DATE and NAME etc. is preceded in the template by "<<" and followed by ">>", without the quotes course. It appears here as "<>". And .Range.Find.Execute("<<"DATE">>" for instance.
>
>Regards,
>
>Paige
>
>**** Snippet ****
>
>oWordDoc = CreateObject("Word.Application")
>WITH oWordDoc
> .Visible = .T.
>*
>SCAN WHILE NOT EOF()
> DO CASE && 0PL = No Prior Letter, 1PL = 1 Prior Letter, 2PL = 2 Prior Letters
> CASE Sel_File.New_LetNo = 0 && No Prior Letters - 0PL
> lcDocument=lcTempDir+"BetExp01.doc"
> CASE Sel_File.New_LetNo = 1 && 1 Prior Letter - 1PL
> lcDocument=lcTempDir+"BetExp02.doc"
> CASE Sel_File.New_LetNo > 1 && 2 0r More Prior Letters - 21PL
> lcDocument=lcTempDir+"BetExp03.doc"
> ENDCASE
>*
>.Documents.open(lcDocument)
>*
> NewText = MDY(DATE())
>*!* DO WordRepl WITH "", NewText
> .Range.Find.Execute("<>",,,,,,,,,"May 13, 2000",wdReplaceAll)
>*
> DO CASE && Checking for Prefix and Middle Name
> CASE ! EMPTY(Ins_Prefix) AND ! EMPTY(Ins_Midd1)
> NewText=ALLTRIM(Ins_Prefix)+' '+ALLTRIM(Ins_First1)+' '+ALLTRIM(Ins_Midd1)+' '+ALLTRIM(Ins_Last1)+' '+Ins_Suffix
> CASE EMPTY(Ins_Prefix) AND ! EMPTY(Ins_Midd1)
> NewText=ALLTRIM(Ins_First1)+' '+ALLTRIM(Ins_Midd1)+' '+ALLTRIM(Ins_Last1)+' '+Ins_Suffix
> CASE ! EMPTY(Ins_Prefix) AND EMPTY(Ins_Midd1)
> NewText=ALLTRIM(Ins_Prefix)+' '+ALLTRIM(Ins_First1)+' '+ALLTRIM(Ins_Last1)+' '+Ins_Suffix
> CASE EMPTY(Ins_Prefix) AND EMPTY(Ins_Midd1)
> NewText=ALLTRIM(Ins_First1)+' '+ALLTRIM(Ins_Last1)+' '+Ins_Suffix
> ENDCASE
>*
>*!* DO WordRepl WITH "<>", NewText
> .Range.Find.Execute("<>",,,,,,,,,NewText,wdReplaceAll)
>
>Replace address etc.


Hi Paige,
Sorry for the long delay. I had some health problems.
Unfortuately I don't have neither of those books. But according to VBA help file that comes with office the full syntax is :

expression.Execute(FindText, MatchCase, MatchWholeWord, MatchWildcards, MatchSoundsLike, MatchAllWordForms, Forward, Wrap, Format, ReplaceWith, Replace, MatchKashida, MatchDiacritics, MatchAlefHamza, MatchControl)

For "expression" you could either use :
Range.Find
Selection.Find

For example "oWord.ActiveDocument.Content" return a range object so this would be legal :
oWord.ActiveDocument.Content.Find.Execute(....

wdReplaceAll is a VBA constant (value = 2). You could get those constants from files section. Also another way to get it to use word itself :
-Select tools\macros\VBE editor
-In code window write wdReplaceAll
-On that word right click and select "quick info"

First if you don't mind I will touch prefix, middlename part a bit :
&& Checking for Prefix and Middle Name
 NewText=chrtran( Alltrim(;
         ALLTRIM(Ins_Prefix)+' '+;
         ALLTRIM(Ins_First1)+' '+;
         ALLTRIM(Ins_Midd1)+' '+;
         ALLTRIM(Ins_Last1)+' '+;
         Ins_Suffix ), '  ', ' ')
Next <<"DATE">> does seem to be a placeholder or mergefield for date() itself. Then instead of find&replace routines I would directly use a word datetime field :

InsertDateTime("MMMM d, yyyy").

Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform