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 / October 2007

Tip: Looking for answers? Try searching our database.

Add a shape text box

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Cresta - 05 Oct 2007 15:55 GMT
Hello and help
I need code to add a shape text box to my document and position it on the
left margin on the next line down from the cursor.

Any ideas
Thanks
Jay Freedman - 05 Oct 2007 16:19 GMT
> Hello and help
> I need code to add a shape text box to my document and position it on
> the left margin on the next line down from the cursor.
>
> Any ideas
> Thanks

It would be much simpler to define a style that includes a properly
formatted frame
(http://sbarnhill.mvps.org/WordFAQs/MarginalText.htm#TrueMarginalText). The
style can be assigned a toolbar button or keyboard shortcut to make it easy
to apply, no macro needed.

If for some reason that doesn't do what you need, then look at the VBA help
for the AddTextbox method of the Shapes collection object, something like

   Dim myBox As Shape
   Set myBox = ActiveDocument.Shapes.AddTextbox( _
       Orientation:=msoTextOrientationHorizontal, _
       Top:=12, Left:=-72, _
       Height:=72, Width:=64, _
       Anchor:=Selection.Range)
   With myBox
       .Fill.Visible = msoFalse
       .Line.Visible = msoFalse
       .TextFrame.TextRange.Text = "hello"
   End With

You'll need to work with this to get the vertical position (.Top) correct,
because the measurement is from the top line of the current paragraph, not
from the cursor position.

Signature

Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.


Rate this thread:






 
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.