Jim Hewson
JHewson at karta.com
Wed Sep 29 16:15:36 CDT 2004
I get it... Think references! Doh! Sometimes I feel like a dolt. Jim -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Jim Hewson Sent: Wednesday, September 29, 2004 3:55 PM To: Access Developers discussion and problem solving Subject: RE: [AccessD] Access form producing a Word document I can't get this to work. It errors out on the first line with the cryptic: "Compile error: User-defined type not defined" I couldn't find anything in help "Word.Application" I'm using A2K if that makes a difference. Thanks, Jim -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Joseph O'Connell Sent: Wednesday, September 29, 2004 9:31 AM To: Access Developers discussion and problem solving; Paul.Rogers at SummitMedia.co.uk Subject: Re: [AccessD] Access form producing a Word document Paul, Create a Word document and instead of typing the text that can change, insert a bookmark using names that are meaningful to you. Save the document. Create a form with 3 text boxes and a command button. The user will enter values into each textbox to be inserted into the Word document. Insert this code for the Click event of the button (insert your own error handling). Dim appWord As Word.Application Dim docWord As Word.Document Dim strFile as String strFile = "insert the complete path to the Word document" Set appWord = New Word.Application Set docWord = appWord.Documents.Add(strFile) docWord.Bookmarks("the name of the first bookmark").Range.Text = Me!txtField1 docWord.Bookmarks("the name of the second bookmark").Range.Text = Me!txtField2 docWord.Bookmarks("the name of the third bookmark").Range.Text = Me!txtField3 appWord.ActiveDocument.PrintOut appWord.ActiveDocument.Close Set appWord = Nothing Set appWord = Nothing strFile = "" Joe O'Connell -----Original Message----- From: Paul Rodgers <Paul.Rogers at SummitMedia.co.uk> To: 'Access Developers discussion and problem solving' <accessd at databaseadvisors.com> Date: Wednesday, September 29, 2004 4:43 AM Subject: [AccessD] Access form producing a Word document |Can an Access form be coded to print a single Word document in which the |text is almost always the same, but for about three fields, please? | |For example, a command button to produce (for the employee whose form it is) |birthday cheers, or a wedding congratulations, or to be fired. | |Cheers |paul | |--- |Outgoing mail is certified Virus Free. |Checked by AVG anti-virus system (http://www.grisoft.com). |Version: 6.0.767 / Virus Database: 514 - Release Date: 21/09/2004 | | |-- |_______________________________________________ |AccessD mailing list |AccessD at databaseadvisors.com |http://databaseadvisors.com/mailman/listinfo/accessd |Website: http://www.databaseadvisors.com -- _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com -- _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com