View Single Post
  #2   Report Post  
Posted to microsoft.public.word.tables
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default populate a word table programatically

Eric wrote:
Any links or tips to do this most appreciated. The data would
currently come from Excel, and get there by VBA. The word doc is
protected with form filling only allowed. v2003 on both.

I posted this on office development as well, as I hadn't seen this
forum first. If there is a more appropriate forum please let me know.

TIA,
Eric


The essential idea for retrieving recordsets (rows) from Excel is shown in
http://www.word.mvps.org/FAQs/InterD...ordWithDAO.htm.

In place of the MsgBox statement in that code, you would need something like
this (assuming the last name is in column A of the worksheet and the first
name is in column B):

With ActiveDocument.FormFields
.Item("LastName").Result = rs.Fields(0).Value
.Item("FirstName").Result = rs.Fields(1).Value
End With

Of course, iterating the rows with While Not rs.EOF doesn't make much sense
for a single Word form unless the worksheet has only one row.

If you get stuck, post back.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.