[AccessD] [dba-OT] Output report to word

Rocky Smolin rockysmolin at bchacc.com
Sat Mar 12 17:52:13 CST 2016


Beautiful.  I'll use that if the rtf approach doesn't work.

Does Word have a macro recorder like excel (which is how I always automate
excel from access) that could show me code for these things?

r
 

-----Original Message-----
From: AccessD [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of
Stuart McLachlan
Sent: Saturday, March 12, 2016 2:54 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] [dba-OT] Output report to word

Here's a code snippet that outputs a variable set of records to a Word
document.
The  document contains an appropriately formatted table with one row.
The Boookmark is in the first column of that row. (Actually there is only
one column in this example).

objWord.Selection.GoTo What:=wdGoToBookmark, Name:="Essential"
 While Not rs.EOF
      objWord.Selection.TypeText Text:=rs!COmpetency & vbCrLf
      objWord.Selection.InsertRowsBelow 1
      rs.MoveNext
Wend
objWord.Selection.Rows.Delete
 
The vbCRLF moves the cursor to the next fcolumn in the table, if you have
more than one - so you don't need to set up multiple bookmarks - just one in
the first column of the initial single row.'
    

On 12 Mar 2016 at 12:06, Rocky Smolin wrote:

> If I do this as a report it will have a couple sub-reports with 
> varying record counts.
> 
> If I set up say four bookmarks across the page and push four values 
> from different fields into them and then push four more, will it make 
> a second line?
> 
> r
> 
> -----Original Message-----
> From: AccessD [mailto:accessd-bounces at databaseadvisors.com] On Behalf 
> Of Susan Harkins Sent: Saturday, March 12, 2016 11:15 AM To: 'Access 
> Developers discussion and problem solving' Subject: Re: [AccessD] 
> [dba-OT] Output report to word
> 
> Rocky I was going to suggest the same thing. It might be your best bet
> -- time-consuming initially, but changes to the Word template would be 
> much simpler than reworking your Access report workaround. And, you 
> know they'll want changes. :)
> 
> Susan H. 
> 
> Is it possible to create a word template with fields, then just write 
> the data across, im in pub at moment but would be abke to help more 
> tomorrow On 12 Mar 2016 18:57, "Charlotte Foust"
> <charlotte.foust at gmail.com> wrote:
> 
> 
> 
> --
> 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



More information about the AccessD mailing list