UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
2 Pages V < 1 2  (Go to first unread post)
   Reply to this topicStart new topic
> Access Query To Word Document, Access 2016    
 
   
tbs
post Jul 11 2019, 09:41 PM
Post#21



Posts: 321
Joined: 12-February 13



how do you drop it to the marked spot in the word doc?


I did something different after failed attempt from the directions MS Office support link above.

I'll write down the steps tomorrow. It involves several steps including exporting the query to a file and having the Word doc link the file.

The problem with this is that the second query, for example, is large. As a result, I am unable to let the table flow into the next page instead of cutting it off. Attached is the word doc so you'll understand what I'm talking about (see page 2).


Attached File(s)
Attached File  Loren.zip ( 22.34K )Number of downloads: 4
 
Go to the top of the page
 
MadPiet
post Jul 15 2019, 09:53 AM
Post#22



Posts: 3,221
Joined: 27-February 09



I guess I have to sit down with Daniel's code and tweak it some.

I think you use the Word.Range object or Word.Selection after doing a find for "put x here". The other way I was thinking of trying to do it was to insert empty tables in the document where the data should go, and then I can just use docWord.Tables(n) and use Daniel's code to inset the data. The only difference is that I would move some variables around so that the Word instance persists for the whole 200 documents. Oh, and then use something like DIR(strPath & "*.docx") to get all the files in the directory and loop over them, but that's trivial. The big thing is matching the query to the right table in Word. But you could store that in a table in your database, and you'd be sorted. Something as simple as

CODE
CREATE TABLE PutTableHere (
          TableNumber TINYINT NOT NULL,
          QueryName VARCHAR(20) NOT NULL);


and then you could just loop through that and drop stuff into your document... <air code (siren)>

CODE
dim rsDocuments As recordset
set rsDocuments = CurrentDb.Querydefs("DocumentsToProcess").openrecordset

do until rsDocuments.EOF
    'Open the Word "template"
     'Process file - do the "merge" into Word (call the function that creates the table and drops it into the proper location) - one for each query
    'close and save Word file
    rsDocuments.MoveNext
Loop
Go to the top of the page
 
2 Pages V < 1 2


Custom Search


RSSSearch   Top   Lo-Fi    25th August 2019 - 10:43 PM