Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linking Word to a VFP Database Field

Status
Not open for further replies.

dobber

Programmer
Aug 18, 2000
21
0
0
US
I have a VFP Database named 2000SALES.DBF. It only contains one field named TOT_SALES. I would like to create a Word Document (Office 2000) named SALES.DOC that will be linked to the field TOT_SALES, so that each time I open up SALES.DOC it will automatically update the link and show the current amount in the field TOT_SALES (this field is being updated on a daily basis with new sales totals).

Does any know the code to do this with? [sig][/sig]
 
So essentially, Dobber, you want to use Word for the data entry of the number?

Regular OLE linking won't work, because that would require a General field in VFP, but you want (I think) a numeric field.

You could do a reverse-COM thingy, where when you save the document in Word a Word VB script is run that updates the value in the VFP table. [sig]<p>Robert Bradley<br><a href=mailto: > </a><br><a href= - Visual FoxPro Development</a><br> [/sig]
 
No I use a VFP Form for all data input. I'm only trying to get Word to link to the database and display the ever-changing sales total from the field. This way I can have a proforma Word document created that will say something like &quot;as of November 1, 2000, our year-to-date sales total is $ &quot;. The document would automatically pull-in the new updated total from the database field each time the document is opened. [sig][/sig]
 
Dobber, I recommend you to read some MS articles about Mail Merge in MS Word, about automation of MS Word (running MS Word from VFP as OLE object) etc. Than you should choose the way that is most appropriate to you. There are many ways to do what you asked for:
1. Mail merge (opening VFP table from Word)
2. Creating document by template and replacing bookmarks by real data from VFP useing OLE automation
3. As Robert said, run Word macro that will do all work.
....
[sig]<p>Vlad Grynchyshyn<br><a href=mailto:vgryn@softserve.lviv.ua>vgryn@softserve.lviv.ua</a><br>[/sig]
 
Now that I better understand what you are trying to do, Dobber, you can use Word COM automation to do the trick.

Here's a quick example using Word's Custom Document Properties:


oWord = createobject(&quot;Word.Application&quot;)

oWord.Documents.Add(&quot;c:\MyTemplate.dot&quot;)

With oWord.ActiveDocument.CustomDocumentProperties

* -- set property values
.item(&quot;Current_Amount&quot;).Value = transform(MyVar, &quot;999,999.99&quot;)

EndWith

oWord.Selection.WholeStory
oWord.Selection.Fields.Update

oWord.ActiveDocument.SaveAs(&quot;c:\MyDoc.doc&quot;)
oWord.Quit
release oWord
[sig]<p>Robert Bradley<br><a href=mailto: > </a><br><a href= - Visual FoxPro Development</a><br> [/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top