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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updateable field in a ms word document

Status
Not open for further replies.

Mike Lewis

Programmer
Jan 10, 2003
17,516
Scotland
Alastair,

This is certainly possible.

How much do you already know about Word Automation? If I give you a starting point here, will you be able to figure it out? Or do you need an explanation from first principles?

I'll assume for now that you know how to get an object reference to your Word document. Here's how you can get the date out of the table:

Code:
* Assume date is in first table in the doc
loTable = loDoc.Tables(1)

* Assume day, month, and year are in row 1, cols 1 - 3
lnDay = loTable.Cells(1,1)
lnMonth = loTable.Cells(1,2)
lnYear = loTable.Cells(1,3)
lcDate = TRANSFORM(DATE(lnYear, lnMonth, lnDay))

* We now have the date. Now it's just a question
* of choosing where we want to put it. Assume
* we'll insert it at start of doc:
loRange = loDoc.Range(1)
loRange.Text = lcDate

Does this help at all? If you need more detail, just shout.

Mike




__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Alastair,

Sorry, I just noticed you said you wanted to insert the date in a field or text box. I'm not sure about fields, but for a text box, change the second half of my code as follows:

Code:
* We now have the date. Now it's just a question
* of choosing where we want to put it. Assume
* we'll insert it in the first text box in the doc.
oRange =  odoc.Shapes(1).TextFrame.TextRange
oRange.InsertAfter(lcDate)

I haven't tested any of this, but I think it should work.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Thanks Mike,
I have done some excel and outlook automation, but not yet with word.
I'll see how I get on.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top