Create word document from scratch, from Access 2007 data

D

Dale Fye

I'm trying to create a word document based on some data in an Access
database, and using some rather convoluted business logic. I don't want to
have to field a document template with my application, so I would like to
create this document from scratch, each time the user selects this option.

I've figured out the processes for opening Word (with either GetObject or
CreateObject), and creating a new document based on the normal template.
What I need to know now is how to:

1. Insert text into a blank document. I've found a couple of posts on how
to place bookmarks, and paste text at the bookmarks, but this is not possible
without sending the document template.
2. Format text as bold/underline (Would like to turn this on and off prior
to inserting some of the text), and then return the format to normal
3. Change the font and fontsize (again, would like to be able to do this
before inserting a block of text and turn it off at the end of the block)
4. Keep track of what line I am on in the document
5. insert a page break

Any help would be greatly appreciated.
 
O

OssieMac

Hello Dale,

You probably would be better to ask this in a Word forum rather than Access.

However, I have tried to do what you want and failed. I had to resort to a
template and I got it working well mostly by inserting fields (DocVariables)
instead of bookmarks where I needed to insert data. (That does not mean it
can't be done by your preferred method; only that I could not do it.)

A lot of what I needed, I found by opening a word document and recording a
macro for what I needed. Note that the default location for word macros is
the Normal.dotm. Suggest you ensure that you set it to the open document so
that it is easy to dispose of.

What I couldn't work out by recording, I found on the ms word communities
site.
 
D

Dale Fye

Duh!

Thanks Ossie. Sometimes I just need to kick me in the head and remind me
that the other Office applications have a record macros functionality. The
solution provided by recording the macro was not very elegant, but it
accomplished the task.

Dale
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top