int64
int64

Reputation: 91

Insert access field into word table

Im trying to create a simple word document from an access database. I have several records that I would like to loop through and write in to tables in word (or just formatted paragraphs... if thats easier). The issues is that from access I can create the table in word but I do not have access to the table cells to write to.

For instance when I perform the following (without the loop):

Dim dTable As Table    
Dim dRow As Row
Set dTable = wrdDoc.Tables.Add(wrdDoc.Paragraphs(1).Range, 2, 2)
dTable.Cell(1,1)... 

This as far as I can get. There is no range property for the Cell in access. Therefore I cannot send the text to a cell in the table. I was expecting something like:

dTable.Cell(1,1).Range.Text = "Some text here" 

or

dRow.Cells(1).Range.Text = "Stuff"

But its not happening. Any feedback on how to push access data to a word document would be appreciated.

Regards,

Upvotes: 1

Views: 600

Answers (1)

int64
int64

Reputation: 91

Thanks for the feedback guys.. I did not know about the mail-merge. I did get this to work but instead of mail-merge I created a 'Saved Exports' on the 'External Data' tab. Its under the 'More' drop down. Here are the steps:

  1. Create a report that is formatted the way you like and select it in the Objects tree
  2. From External Data --> More --> Word (Export the selected object to a rich text box)
  3. Select 'Open the destination..." to open the word doc after the export (if you like)
  4. Save the export procedure.

From an access form you can create a button that will fire off this procedure. Just add a DoCmd to the buttons control...

DoCmd.RunSavedImportExport (reportName)

Thanks again for the help,

Upvotes: 0

Related Questions