Replace text in cells

S

Sol Apache

I want to select text in a cell of a table where the cursor is and replace
it with an autotext entry. This macro selects the cell, but I get an error
message when I try to replace the text:

ActiveDocument.Tables(1).Cell(1,2).Select
NormalTemplate.AutoTextEntries("Attention:").Insert Where:=Selection.Range

Any help appreciated.


Sol
 
S

Sol Apache

Just realised that this macro selects the first table in the document, and I
have several. I want to select the second cell of row 1 of the table in
which the cursor is, then replace it with an autotext entry, as set out
below.

The learning curve for VB is steep...
 
G

Greg Maxey

Sub Scratchmacro()
Dim oRng As Word.Range
Set oRng = Selection.Tables(1).Cell(1, 2).Range
oRng.MoveEnd wdCharacter, -1
NormalTemplate.AutoTextEntries("Attention:").Insert oRng
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