Problem with moveup -- moves 3 lines not 1 what's up?

A

Al

BACKGROUND:

I use MS Office 2000. In an MS Word document, I have a table that is 5
columns wide, and 8 rows long. There are 3 header lines, and 5 detail lines.


I load the detail lines from an MS Access Database and MS Access VBA program
which works fine.

The entire outer table gridlines are highlighted so it looks like a table
with a box around it.

When access loads the table the last line is blank (which contains the
original formatting). This line is deleted. I move the cursor up a line and
then the last line in the table is selected and the formatting added back.
Below is the program.

Set appword = GetObject(, "Word.Application")

'FORMAT LAST ROW IN TABLE & BOTTOM TABLE LINE
1. appword.Selection.Rows.Delete
2. appword.Selection.MoveUp Unit:=wdLine, Count:=1
3. appword.Selection.SelectRow
4. With Selection.Cells
5. With .Borders(wdBorderBottom)
6. .LineStyle = wdLineStyleSingle
7. .LineWidth = wdLineWidth050pt
8. End With
9. End With

My problem that line 2 of the program moves the cursor up three lines
instead of just one.

If I have MS Word open at the time I run the Access VBA code it only moves 1
line as expected.

QUESTION:
How can I control the cursor to move up only one line instead of 3 lines?
 
W

Word Heretic

G'day "Al" <[email protected]>,

Don't use the selection object, use your own range object.

Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice


Al reckoned:
 
A

Al

Steve,

Thanks for your reply. I've not used ranges in MS Word. I'll have to try
that.

I was able to solve this delima by changing the border properties of the
entire table to be highlighted. This way when I delete the last row the
table remembers the border properties not the line.

Thanks again!

Al
 

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