4 |
The LA Fox Developer Newsletter
|
September 1999
|
Release WrdObj
*
Close all VFP tables CLOSE TABLES
End of Program
II. EXAMPLE 2; Creating and Filling in a Table in Word 95 from VFP 6.0
1. This example uses a tip from the article Getting Started With Automation FoxPro Advisor, July 99, page 44 using the macro recorder in WORD to figure out WordBasic commands
2. Start VFP and copy form vfp_wordl .scx to c:\tmp\vfp_word2.scx
3. Start Word, select TOOLS/MACRO/RECORD and name it vfpdemo
4. Within WORD, Select TABLE! INSERT TABLE!3 col, 2 rows
and within the table, type in: Name (tab) Work Phone (tab)
Pager (tab) Mike (tab) 436-7466 (tab) 123-553 (tab)
5. Now click on the macro stop button and then TOOLS! MAC RO/vfpdemo!EDIT. You should see the following:
Sub MAIN
Tableinsertlable .ConvertFrom
=
““,
.NumColumns
=
“3”, .NumRows
=
“2”, .lnitialColWidth
=
“Auto”, Format:: “0”, .Apply =167”
Insert “name’
NextCell
Insert “work phone”
NextCell
Insert “pager”
NextCell
Insert “Mike”
NextCell
Insert “436-7466”
NextCell
Insert “123-553”
InsertPara
TablelnsertRow .NumRows
““
End Sub
|
COPY this text and PASTE it at the end of the code of the VFP
Print button CLICK event.
6. To convert Word Basic commands to VFP commands.
• Delete the SUB first line and End Sub last line
• Before each line insert WrdObj.
• Put parentheses around all quotes
• in the Tablelnsert and TablelnsertRow commands remove all
•XXX= and just leave the values in parentheses.
Place this code between the START and END comment lines and replace the Insert “Mike” with insert(cName); do same for work telephone # and pager #; then put this code in a DO
WHILE loop so you get the following:
.NumColumns
=
“3”, .NumRows
=
“3”,
•lnitialcolWidth =
“Auto”, .Format
=
“O”,.Apply
=
“167”
WrdObj.TablelnsertTable(”, “3”, “2”, “Auto”,”O”,”16T’) WrdObj.lnsert( “name”)
WrdObj.NextCell
WrdObj.lnsert (“work phone”) WrdObj.NextCell
WrdObj.Insert (“pager”)
DO
WHILE
NOT EOFØ
WrdObj.NextCell
WrdObj.lnsert (cName)
WrdObj.NextCell
WrdObj.lnsert (cWorKTel)
WrdObj.NextCell
WrdObj.lnsert (cPager)
WrdObj.InsertPara
TablelnsertRow .NumRows
=
WrdObj.TablelnsertRow(
“)
ENDDO
Finally in the code, replace the SAVE AS file with “c:\tmp\phonelist.doc”
7. Build and Run the project and then check out the resultant c:\tmp\phonelist.doc
Ill. EXAMPLE 3. Automating files conversion
and distribution via email
1. BACKGROUND:
Every morning between 1-4 am, six mainframe reports are run and stored as a2mjml .001, a2mjm2.001 through a2mjm6.001. Using a VFP executable, the mainframe files are converted to dbf format using MONARCH software. Then they are zipped using PKZIP and finally emailed to a distribution list using
Microsoft Exchange.
(Con't, Page
5)
|
Page 4
|
4 |