Range:={Where the cursor is)

M

Mark Jerde

Sorry if these are the wrong newsgroups. Please tell me where I should have
posted.

Office 2003. Using VBA in MS Access for now.

I'm trying to create a Word document from a Microsoft Access database. The
database is a typical Parent/Child db where each parent has zero to perhaps
30 children. In the Word document I want to print out each parent then for
each child create a 7x2 table and populate it with the child info. I can
create the parent info just fine, and I can fill in the tables with the data
desired, but I can't make the table show up in the right position. What I'd
like to do is below:

oApp.ActiveDocument.Tables.Add NumRows:=7, NumColumns:=2, _
Range:=(oApp.CurrentCursorPosition,
oApp.CurrentCursorPosition)

That is, the parent information has been put into the Word document, and now
I want to put zero to 30 7x2 tables below. Everything I've tried has
either errored or put the tables in the wrong place.

Two questions.

1. How can I, in VBA, move the "cursor" to the end and insert a 7x2 table
and then populate it?

2. How could I have found this answer via efficient googling? All the
searching I've done has yielded nothing.

Thanks!

-- Mark
 
J

John Nurick

Hi Mark,

The best newsgroup would probably have been
microsoft.public.word.vba.general; also, see http://word.mvps.org ,
which is the best single source of information about making Word do what
you want.

As far as I can remember, if you want to get to the end of something,
set the appropriate range and collapse it, e.g.

Dim R as Word.Range

Set R = oApp.ActiveDocument.Range
R.Collapse wdCollapseEnd
R.Tables.Add NumRows:=7, NumColumns:=2
...
 

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