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

hi..

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
navamnkAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Steve KnightIT ConsultancyCommented:
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.

ii)

ActiveDocument.Shapes("TextBox1").Select
Selection.InlineShapes.AddPicture FileName:=file$, LinkToFile:=False, SaveWithDocument:=True

iii)

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.



Steve

0
MacroWizardCommented:
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.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bruintjeCommented:
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:
http://www.experts-exchange.com/help/closing.jsp

PLEASE DO NOT ACCEPT THIS COMMENT AS ANSWER

HAGD:O)Bruintje
EE Cleanup Volunteer
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Office

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.