>OK - I took your advice - I've never worked much with Word macros, so this too was a stretch :)
It *is* different than VFP, but not so much so! It gets easier the more you do it <s>.
>
RecentFiles(1).Open
> Selection.MoveDown Unit:=wdLine, Count:=1
> Selection.TypeParagraph
> Selection.TypeParagraph
> Selection.MoveUp Unit:=wdLine, Count:=2
> Selection.InsertDateTime DateTimeFormat:="MMMM d, yyyy", InsertAsField:= _
> False
> Selection.TypeParagraph
> Selection.TypeParagraph
> Selection.TypeText Text:="Line 1"
>
>I have a handle on opening the file, so the first line isn't a problem. But even after looking at the KB article you provided, I was unable to turn this into VFP code. I have a local variable in my method code that contains the name and address (l_address) that I want to go where the "Line 1" text is now....
OK -- I'm kinda in a time crunch, so I'll give you some pointers to fix up the code...but I haven't taken it out and tested it in VFP (just wanted to give you fair warning that you may have to fuss with a few things).
Think of the Selection object is your current place in the document. You can store this as a Range. A Range is also a place in the document, but it can be referenced again and again even if the Selection (current place) changes. You can have many Ranges in the document--only one Selection. Ranges are generally considered more efficient. So make it a Range object with:
oRange = oDocument.Selection.Range()
Now use WITH oRange...ENDWITH around all those Selection lines, and delete "Selection" (leave the "." <s>).
The Unit:=wdLine is a "named parameter." VFP doesn't support them, so you need to remove them <s>. Simply delete the parameter name and the := characters. Then properly format the method call by putting parentheses around the parameters. For example, that first line becomes:
WITH oRange
.MoveDown(wdLine, 1)
ENDWITH
That "wdLine" reference is a constant. These are built into VB/VBA, but we need to use #DEFINE to assign a value to it. In this case, wdLine has a value of 5. Where do you find the constants? I'll point you to a FAQ that Tamar Granor and I wrote for our book; the very last question has the answer on where to find the constants:
http://www.hentzenwerke.com/catalog/autofoxfaq.htmFix the InsertDateTime and TypeText methods the same way we fixed MoveDown. If you wind up with it squawking about wrong data types or a wrong number of parameters, chances are that the macro recorder listed them out of order. Look up the proper syntax in the VBA Word Help file; on my machine, it's at C:\Program Files\Microsoft Office\Office\1033\VBAWRD9.CHM. If it's not on your machine, you'll have to install it from the original Office CDs.
Might I also suggest that you take a look at the book Tamar and I wrote? It's called _Microsoft Office Automation with Visual FoxPro_. If you order through Hentzenwerke, they'll send you an email with the userid/password to allow you to download the text of the book in a .CHM without having to wait for the book to be shipped to you.
Hope this helps!
- della