Autotext Insert in Cell Using Range 
Author Message
 Autotext Insert in Cell Using Range

I'm trying to insert an autotext into a cell.  The
following works, but I want to not use the Selection.Range
in the where of the Autotext instead of having to resort
to using a selection.  I've tried "Where: Sec.Range.Tables
(1).Cell(3,1).range.characters.first", but I still get an
error.

Any suggestions?

For Each Sec In ActiveDocument.Sections
If Sec.Range.Paragraphs(1).Range.Style = "Chapter Title"
Then
Sec.Range.Tables(1).Cell(3, 1).Select
Selection.Delete
Selection.Collapse (1)
ActiveDocument.AttachedTemplate.AutoTextEntries
(MyBanner).Insert Where:=Selection.Range, RichText:=True
Next Sec



Mon, 06 Dec 2004 14:01:34 GMT  
 Autotext Insert in Cell Using Range
Hi Jason,

Use something like:

--------------------------------------------------------------
Dim oRange As Range

Set oRange = ActiveDocument.Tables(1).Cell(2, 1).Range

oRange.Collapse wdCollapseStart

NormalTemplate.AutoTextEntries("In regards to:").Insert _
    Where:=oRange, RichText:=True
--------------------------------------------------------------

Hope this helps.
ibby

Please post replies or follow-ups to the **newsgroup** so that participants
may benefit or contribute.


Quote:
> I'm trying to insert an autotext into a cell.  The
> following works, but I want to not use the Selection.Range
> in the where of the Autotext instead of having to resort
> to using a selection.  I've tried "Where: Sec.Range.Tables
> (1).Cell(3,1).range.characters.first", but I still get an
> error.

> Any suggestions?

> For Each Sec In ActiveDocument.Sections
> If Sec.Range.Paragraphs(1).Range.Style = "Chapter Title"
> Then
> Sec.Range.Tables(1).Cell(3, 1).Select
> Selection.Delete
> Selection.Collapse (1)
> ActiveDocument.AttachedTemplate.AutoTextEntries
> (MyBanner).Insert Where:=Selection.Range, RichText:=True
> Next Sec



Mon, 06 Dec 2004 15:06:52 GMT  
 Autotext Insert in Cell Using Range
Yes, I think that will do it.  Didn't know you can
collapse like that.  

Thanks!

Quote:
>-----Original Message-----
>Hi Jason,

>Use something like:

>----------------------------------------------------------
----
>Dim oRange As Range

>Set oRange = ActiveDocument.Tables(1).Cell(2, 1).Range

>oRange.Collapse wdCollapseStart

>NormalTemplate.AutoTextEntries("In regards to:").Insert _
>    Where:=oRange, RichText:=True
>----------------------------------------------------------
----

>Hope this helps.
>ibby

>Please post replies or follow-ups to the **newsgroup** so
that participants
>may benefit or contribute.



>> I'm trying to insert an autotext into a cell.  The
>> following works, but I want to not use the
Selection.Range
>> in the where of the Autotext instead of having to resort
>> to using a selection.  I've tried "Where:
Sec.Range.Tables
>> (1).Cell(3,1).range.characters.first", but I still get
an
>> error.

>> Any suggestions?

>> For Each Sec In ActiveDocument.Sections
>> If Sec.Range.Paragraphs(1).Range.Style = "Chapter Title"
>> Then
>> Sec.Range.Tables(1).Cell(3, 1).Select
>> Selection.Delete
>> Selection.Collapse (1)
>> ActiveDocument.AttachedTemplate.AutoTextEntries
>> (MyBanner).Insert Where:=Selection.Range, RichText:=True
>> Next Sec

>.



Mon, 06 Dec 2004 15:30:30 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Insert Autotext - returned range depends on formatting?

2. Macro that inserts Autotext loses styles of Autotext entry

3. Inserting Autotext using VBA - loses formatting and styles

4. Problem with format on insert autotext, and in inserting elements with form fields

5. I need to get a cell or range of cell from Excel

6. I need to get a cell or range of cell from Excel

7. Delete range of cells in Excel using Access

8. Word automation: Using a Range object to Insert Para

9. inserting cell contents using FormattedText

10. better way? autotext in table cells

11. How do I select a constant time range from a variable time range using VBA

12. Inserting AutoText in Header and retaining formatting

 

 
Powered by phpBB® Forum Software