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 / February 2006

Tip: Looking for answers? Try searching our database.

Inserting text at a specific point via VBA?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ML - 08 Feb 2006 14:37 GMT
I am currently doing the following to insert text at a specific point and it
works fine but I'd rather just code the text directly rather than reference
an autotext entry.  How can I do this in a similar fashion to below?  Only
autotext seems to have the insert method.

Set a = ActiveDocument.AttachedTemplate.AutoTextEntries("ORCON")
a.Insert Where:=Selection.Range, RichText:=True
Cindy M  -WordMVP- - 08 Feb 2006 15:04 GMT
Hi Ml,

> I am currently doing the following to insert text at a specific point and it
> works fine but I'd rather just code the text directly rather than reference
[quoted text clipped - 3 lines]
> Set a = ActiveDocument.AttachedTemplate.AutoTextEntries("ORCON")
> a.Insert Where:=Selection.Range, RichText:=True

ActiveDocument.Content.Text = "This is my text"

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :-)
Greg - 08 Feb 2006 15:36 GMT
Here are a few:

Sub Test()
Selection.TypeText "Hello ML"
'or
Dim oRng As Word.Range
Set oRng = ActiveDocument.Content 'or some other range
oRng.Text = "Hello ML"
End Sub
ML - 08 Feb 2006 16:32 GMT
Thanks.  I should note that I also need to be able to set the font
properties.  That seems to be the part I'm missing now.

Ex:
   Dim fHidden As New Font
   'Setup hidden font for marker
   fHidden.Hidden = True
   fHidden.Bold = True
   fHidden.Color = wdColorOrange
a.Insert(Where:=Selection.Range, RichText:=True).Font = fHidden

> Here are a few:
>
[quoted text clipped - 5 lines]
> oRng.Text = "Hello ML"
> End Sub
Helmut Weber - 08 Feb 2006 16:57 GMT
Hi ML,

how about this one:

Sub test09()
Dim fHidden As New Font
fHidden.Hidden = True
fHidden.Bold = True
fHidden.Color = wdColorOrange
Dim sTmp As String
sTmp = "aaa"
With Selection
  .Text = sTmp
  .Font = fHidden
End With
End Sub
Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

 
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.