Moving Around a Word Document

saross

Registered User.
Local time
Today, 14:06
Joined
Mar 4, 2003
Messages
120
Hi all.

Thanks to this forum, I managed to work out how to throw my data out to a word document (I hope! I haven't quite finished testing it yet!)

But, I need to move the cursor across cells where I can't use bookmarks and am not sure how to do this! Previously, I've called datasets from within word and used:
Selection.GoTo What:=wdGoToBookmark, Name:="Milestones"
Selection.TypeText vbNullString & .Fields(1)
Selection.MoveRight Unit:=wdCell
Selection.TypeText vbNullString & .Fields(2)
Selection.MoveRight Unit:=wdCell
etc..

but now I'm working from within the database, and using the following structure:
objWord.ActiveDocument.Bookmarks("Milestones").Select
objWord.Selection.Text = vbNullString & .Fields(2)
... what next? How do I move across the cells of a table?

Any help would be greatly appreciated!!!

Thanks.
 
Moving in a table

This moves on cell to the right.

objWord.Selection.moveright 12


This is some code I have used before and gives the jist of what you need.

' objword.selection.Shading.Texture = 150
objword.selection.Shading.BackgroundPatternColorIndex = 7
objword.selection.font.bold = true
objWord.Selection.TypeText "TOTAL"
objWord.Selection.moveright 12
objword.selection.Shading.Texture = 0
objword.selection.font.bold = true
objWord.Selection.TypeText formatnumber(tot,2)
objword.selection.font.reset
 
Thanks for this. I tried the 'MoveRight' but it doesn't move the cursor to the next field in the table. I guess I need the equivalent of the 'TAB' key - but does anyone know what that is?
:(
 
Dim Memory

My memory is a bit dim on this but I am absolutley sure that it works. Used in a Gov job and builds remittances for Millions of £s !!!

The 12 is the 1 cell bit.
Equiv to wdCell
 
D'oh!!! I assumed the 12 was the number of spaces and cut it down to 1... I've tried it with 12 and it works perfectly!!! Thank you very much!!! :D
 
Easy cheat

If you get stuck on how to do this in terms of fonts, formats etc. I just opena word doc, start a macro, then do all the bits including the movright and then look at the code it generated.
 

Users who are viewing this thread

Back
Top Bottom