By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,294 Members | 2,588 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,294 IT Pros & Developers. It's quick & easy.

Exporting a database in Access to a form in Word

P: 1
I just cannot see clearly now...or I am just stupid, but I need a little help to getting the file ready in Access for the form that awaits it in Word.

Now I think the correct procedure is that I set up a form in Word using the same field names in Access, but I'm not sure. I am running a Class Reunion database in which I have adding data for the last six months. Now I'm ready to send it into Word, buy I'm not sure what feature I need to run in Access in order to do this.

If any of you might have a shortcut or two for me, I would appreciate it.

Thank you.
Aug 14 '08 #1
Share this Question
Share on Google+
1 Reply


ADezii
Expert 5K+
P: 8,638
I'm a little hazy on exactly what you are requesting, but here is a little code segment that will print the First and Last Names in the Employees Table of the Northwind Database, to a File named Northwind.doc in the C:\Test\ Directory. This is accomplished via Automation. Be sure to set a Reference to the Microsoft Word XX.X Object Library.
Expand|Select|Wrap|Line Numbers
  1. Dim MyDB As DAO.Database
  2. Dim rstWord As DAO.Recordset
  3. Dim objWord As Word.Application
  4.  
  5. Set MyDB = CurrentDb
  6. Set rstWord = MyDB.OpenRecordset("Employees", dbOpenForwardOnly)
  7.  
  8. Set objWord = CreateObject("Word.Application")
  9.  
  10. objWord.Documents.Add
  11.  
  12. With rstWord
  13.   Do While Not .EOF
  14.     objWord.Selection.TypeText ![FirstName] & " " & _
  15.                                ![LastName] & vbCrLf
  16.     .MoveNext
  17. Loop
  18. End With
  19.  
  20. objWord.ActiveDocument.SaveAs FileName:="C:\Test\Northwind.doc"
  21.  
  22. objWord.Quit
  23. Set objWord = Nothing
  24.  
  25. rstWord.Close
  26. Set rstWord = Nothing
Aug 21 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.