Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Word Macro to be called from VFP
Message
De
28/08/2000 19:42:10
 
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00409726
Message ID:
00410083
Vues:
19
Thanks Della,
I have the book and it does not give what I need.

I can find "PAGE:"
but then the vba junk becomes unusable.
I don't know how to translate those named parameters
Selection.Find.Execute
Selection.HomeKey Unit:=wdLine
Selection.MoveDown Unit:=wdLine, Count:=5, Extend:=wdExtend
Selection.Font.Bold = wdToggle
If Selection.Font.Underline = wdUnderlineNone Then
Selection.Font.Underline = wdUnderlineSingle
Else
Selection.Font.Underline = wdUnderlineNone
End If

All I want if I find the word 'PAge:' got to beginning of line, do the equivalent of ctrl shift down,ctrl U (select current line and underline it.

and then how to find the next occurance of 'PAGE:"



thnaks

great book though

>Peter,
>
>Sounds like you need to do some Automation work! It's not hard. The easiest way to get the basis for the code you want is to go to Word and open a new document. Turn on the macro recorder, and interactively perform all the searches/replaces and so forth. (Keep it to a reasonable number of steps, say, open the file, and do one or two search/replaces -- you can always run the macro recorder again to collect the formatting steps, and again to do something else.) When finished, turn off the macro recorder, then edit the macro. Now you have VBA code. And it looks *sorta* similar to VFP code, with some notable exceptions. Copy this code to the clipboard.
>
>Now go into VFP. Open a new program (or method), and paste it in. At the top, you'll want to give the following lines:
>
>oWord = CreateObject("Word.Application")
>oWord.Visible = .T.
>WITH oWord
>
>Then you'll convert all the code into VFP. Generally you'll put a period in front of the properties/methods (you're in the WITH), and remove the named parameters (the "Name:=" part -- just delete it, and hope it wrote the parameters out in the right order.) Add the last ENDWITH line, and you're ready to run (and start debugging the errors...oops, I mean "fine tuning" <vbg>).
>
>There are plenty of online docs here at the UT for help on Automation. Also try searching the MSDN KB for "foxpro word automation" -- it nets *some* stuff (though the stuff here is probably better!). And finally, the "best" source (if I do say so myself) is the book Tamar Granor and I wrote called "Automating Microsoft Office from Visual FoxPro" available at www.hentzenwerke.com -- it covers all this and has some good examples to show text and formatting Search and Replace.
>
>Once you get started, post some more specific questions, and I think we can help you.
>
>Hope this helps!
>
> - della Martin
>
>>I create a word document from within VFP for local printing. The straight text will be sent to a AS400 for publishing and the pagination on that machine is as asenine as it can get.
>>Anyway there are not formfeed anywhere.
>>
>>No in order to print it also locally I desided to send the text to MSWord.
>>Now I need to do the following:
>>
>>Find the all instances of the word PAGE:, go to the beginning ofthe line, insert a pagebreak and also make the line Bold and Underlined.
>>
>>(there are apprximately 500 pages)
>>
>>
>>And as another challange I need to overlay a form over the text. Like preprinted text, lines between columns and lines every fourth row and the like.
>>
>>Any ideas anybody ??
>>
>>Thanks
>>
>>Peter
>>
>>PS. I don't know VBA at all. There seems to no do while not eof() equivalent.
Peter Cortiel
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform