Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


How to: create a textbox inside the Word document....?

Posted on 2003-02-27
Medium Priority
Last Modified: 2012-05-04

By using Macros

i.  how can i place a textbox in the current cursor position. b'cause when creating a textbox (using ActiveDocument.Shapes.AddTextbox method), i don't know the exact position of the left, top, width, height parameters in the AddTextbox method and these parameters dynamically varies. so that how can i get the cursor position.

ii. how can i place an image inside the textbox

iii. is there any option to hide/show the textbox in the word document

thnks in advance
Question by:navamnk
LVL 43

Expert Comment

by:Steve Knight
ID: 8040301
1) Not sure.  I've always worked with predfined text boxes but then used the left, top, etc. paramaters to fix their position within the code.


Selection.InlineShapes.AddPicture FileName:=file$, LinkToFile:=False, SaveWithDocument:=True


ActiveDocument.Shapes(i).Height = 0 (having recorded the height paramater to set it back later if you need...)

You can also use the Zorder property to "hide" multiple images behind each other.



Accepted Solution

MacroWizard earned 90 total points
ID: 8041195
Here, try this code. This will give you a little tiny text box at the cursor position (selection.range), with 0 as the top parameter and 0 as the left parameter. Obviously change these parameters as you see fit.

One tip. Always find out what the name of your shape is (Word automatically gives them names). That way you can maniputlate it any way you want later. Sometimes I rename the shapes beginning with, say "MW", so later on I know which shapes are mine and which the user put in. That way I can work with only my shapes.

Example, pleading lines in a document. I add the lines to the header and name them "PL" plus whatever Word has named them. That way I can easily go in and delete all shapes starting with "PL." See example below.

Dim strname As String

' add shape and get its name
strname = ActiveDocument.Shapes.AddTextbox(msoTextOrientationHorizontal, 0, 0, 20, 20, Selection.Range).Name

' Rename shape
activedocument.Shapes(strName).Name = "PL" + strName

Regarding hiding the shape, I found the visible parameter but have never tried it. This would argue more for you to name your shapes, so you can change the visibility of the shapes.

ActiveDocument.Shapes(strname).Visible = msoFalse

Hope this helps.
LVL 44

Expert Comment

ID: 9283620
This question has been classified as abandoned.  I will make a recommendation to the moderators on its resolution in the next round.  I would appreciate any comments by the experts that would help me in making a recommendation.

It is assumed that any participant not responding to this request is no longer interested in its final deposition.

If the asker does not know how to close the question, the options are here:


EE Cleanup Volunteer

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Microsoft's Excel has many features that most people will never need nor take advantage of.  Conditional formatting is one feature that you may find a necessity once you start using it.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question