Going to specific cells in a table

D

Doc60

I would like to know how I can program into a macro the ability for the
cursor to goto a specifc cell in a table. For example cell F5.

Thank you
 
G

Greg Maxey

Sub ScratchMacro()
Selection.Tables(1).Cell(5, 6).Range.Select 'For the current table
Selection.Collapse wdCollapseStart
'Or
ActiveDocument.Tables(1).Cell(5, 6).Range.Select 'For the first table in the
document
Selection.Collapse wdCollapseStart
End Sub
 
F

fumei via OfficeKB.com

Or, depending on your requirements, use a bookmark. If a cell is bookmarked,
and it is named "test", you can move the Selection to it, and select it by:

Selection.GoTo what:=wdGoToBookmark, Name:="test"

If you want to move the Selection to it, but NOT select it - ie. you want the
cursor at the start of it:

Selection.GoTo what:=wdGoToBookmark, Name:="test"
Selection.Collapse Direction:=wdCollapseStart

If you want to simply display the content of what it there, and again the
cell is bookmarked as "test"

MsgBox ActiveDocument.Bookmarks("test").Range.Text

BTW: I will assume by cell F5 you mean Row 6, Column 5. Word is not Excel.
 

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