Word Macro Help

S

Shell

I have a word document consisting entirely of a table, many columns and many
rows. How can I in vb code(macro) select some text and move it to another
cell in the table, change its font , etc.

I tried to use the record new Macro, but I couldn't select any text.

Thanks
 
G

Greg Maxey

This example moves the text from row 2, column 2 to row 8 column 8 and
formats the text:
Sub ScratchMacro()
Dim oTbl As Word.Table
Dim oCellRng As Word.Range
Set oTbl = Selection.Tables(1) 'or ActiveDocument.Tables(i)
'where i is the number of the table in the document
'the first being 1
With oTbl
Set oCellRng = .Cell(2, 2).Range
oCellRng.MoveEnd 1, -1
.Cell(8, 8).Range = oCellRng.Text
.Cell(2, 2).Range.Delete
With .Cell(8, 8).Range
.Font.Name = "Times New Roman"
.Font.Bold = True
End With
End With
End Sub
 

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