Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 16th, 2005, 05:10 PM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default Word Merge with Access VBA

I need to merge data from Access into a Word Document using VBA in Access. I have found several solutions online, but all are very complex and full of bugs. Does anyone know a good simple way to Open a document, merge data in from Access, or directly assign values to merge fields, and the allow the user to print or save the document?

Thanks in advance.

Mike

Mike
EchoVue.com
__________________
Mike
EchoVue.com
 
Old October 16th, 2005, 05:22 PM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Not to worry...

I found some very simple code that works well - It may not be the best way of doing it, but it should work, and keep it all very simple.

 Dim objWord As Object

 Set objWord = GetObject("C:\WordDocs\Agreement.doc")

 objWord.Application.Visible = True
 objWord.Bookmarks("CompanyName").Select
 objWord.Application.Selection.Text = "ACME Corp Limited"

This pulls it up in Word, and then I can let the user manipulate it, or do whatever from there.

Thanks

Mike

Mike
EchoVue.com
 
Old October 16th, 2005, 05:38 PM
Authorized User
 
Join Date: Oct 2005
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Figgis
Default

I suppose the other way you could do it is to create a report in Access and then show the user how to publish it with word. That's all I've ever done. There probably is a VBA method for doing the same thing but as its so easy to do I have never bothered doing it any other way
 
Old October 16th, 2005, 05:43 PM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Huh! I have never played with the Publish to Word functions. Does that effectively just move the report to word so that the user can edit it?

Thanks

Mike

Mike
EchoVue.com
 
Old October 16th, 2005, 06:58 PM
Authorized User
 
Join Date: Oct 2005
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Figgis
Default

yes pretty much. you have to preview the report first then you can publish with Word or Excel. I think you could probably set up a macro to handle it if you did not want the users to manually choose what to do with it
 
Old October 17th, 2005, 11:24 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Thank Figgis,

This probably isn't the best solution for this particular problem, but I have another that I have been working on for a while, that this will save a lot of headaches on.



Mike
EchoVue.com
 
Old May 5th, 2006, 05:11 PM
Registered User
 
Join Date: May 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

where is the best place to place this code to open as a word document when opening a report?





Similar Threads
Thread Thread Starter Forum Replies Last Post
"Pushing" from Access to Word via Mail Merge Loralee BOOK: Access 2003 VBA Programmer's Reference 2 March 8th, 2006 10:20 PM
Access launching Word for mail merge Loralee Access 8 November 14th, 2005 04:24 PM
Access/Vba mail merge to word help alfonse Access VBA 0 July 28th, 2005 05:11 AM
Access to word merge missing link ? blade59 Access VBA 0 September 9th, 2004 04:36 PM
Access OLE Merge to Word GregoryHu Access VBA 5 May 7th, 2004 10:18 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.