Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / April 2007

Tip: Looking for answers? Try searching our database.

Replace text in cells

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sol Apache - 18 Apr 2007 22:12 GMT
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
Sol Apache - 18 Apr 2007 22:33 GMT
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...

On 18/4/07 22:12, in article C24C483B.481D%sol@solapache.com, "Sol Apache"
<sol@solapache.com> wrote:

> 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
[quoted text clipped - 6 lines]
>
> Sol
Greg Maxey - 18 Apr 2007 23:08 GMT
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

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> 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
[quoted text clipped - 17 lines]
>>
>> Sol
Sol Apache - 18 Apr 2007 23:25 GMT
That works perfectly, Greg. Thank you very much.

On 18/4/07 23:08, in article eS7naYggHHA.4260@TK2MSFTNGP03.phx.gbl, "Greg
Maxey" <gmaxey@mvps.oSCARrOMEOgOLF> wrote:

> 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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.