Automaticly Insert bookmarks

J

Jimmy25

Hey all!

I'm after a Word VBA code to automatically bookmark each cell in a table
with a prefix and the relevant row number, so that:

prefix = Alpha
row1 = "alpha"&"1"
row2 = "alpha"&"2"

This is the last step of my grand scheme to get excel to talk to word so any
help would be much appreciated!
 
M

macropod

Hi Jimmy,

Since you can address table cells in word with a row & column reference, there's really no need to bookmark the cells. In the long
run, using bookmarks this way is likely to create more problems than it solves.
 
D

Doug Robbins - Word MVP

Use

Dim i As Long, j As Long
With ActiveDocument.Tables(1)
For i = 1 to .Rows.Count
For j = 1 to .Columns.Count
.Cell(i, j).Range.Bookmarks.Add Chr(64 + j) & i
Next j
Next i
End With

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

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