PDA

View Full Version : Add ActiveX Textbox



Macropheliac
10-09-2006, 11:47 AM
Hello all!
I am brand new to Word and I don't seem to be grasping it very well.:dunno

Is it possible to add an ActiveX textbox to a document without it moving the existing text? In other words, when I add a textbox via the Control Toolbox, it moves everything over and changes the formatting. Can it be placed so that it floats on top instead of embedding itself, such as in Excel?

Any help is appreciated.


Thanks,
Mac

fumei
10-10-2006, 12:20 PM
This is a scary part of Word. You need to really look up the difference between an InlineShape, and a Shape.

ActiveX controls are, by default, InlineShapes. Because they are IN line, they are considered part of the text. They can not "float".

Shapes can float.

You can convert an InlineShape to a Shape and make it float. Sort of. It is tricky. As a Shape it has an Anchor, and the Anchor can be moved. However, it is not - assuming a conversion of an ActiveX textbox from InlineShape to Shape - in a frame so while it can be moved, it is NOT floating freely.

More importantly....

Why are you trying to do this?
Why are you doing this by code?

An ActiveX textbox should be used (IMHO) for ONE thing only....text input by the user.

Macropheliac
10-10-2006, 06:00 PM
Thanks, Fumei, for your help.

I suppose I will have to use the shape, as you suggested. It will work for what I need.

To answer your questions:


Why are you trying to do this?


It is an attempt to automate a document we use. I can't change the text or the formatting of the document in any way, as it is a "Safety" document. I can only add a couple of textboxes and some code so that the information is entered into the correct place in the document. I've tried to convert the document to Excel, but failed. Whomever built the document, originally, apparantly had no intention of anyone ever using a computer. Oh well! Those are the breaks.



Why are you doing this by code?


As I said before, I am new to Word. I have always used Excel. I thought this might be a good oppertunity to learn a bit about Word and Word VBA.

I very much appreciate your time and help.

Thanks,
Mac

fumei
10-10-2006, 06:15 PM
Well, it IS an opportunity to learn Word VBA. However, you did not really explain what you are doing.
It is an attempt to automate a document we use. I can't change the text or the formatting of the document in any way, as it is a "Safety" document. I can only add a couple of textboxes and some code so that the information is entered into the correct place in the document.Hmmmm, most of what we try to do with Word and VBA is some sort of automation of Word...so that does not tell me much.

A great deal of what I do is get information from the user and have it is the correct place in the document. But I rarely use ActiveX textboxes for this. So again, your explanation does not really help.

WHY an ActiveX textbox? "Correct" place? If the textbox is put the document, then hopefully you put it in the correct place. WHY do you want to put it in with VBA?

WHY do you want a floating textbox? WHAT do you want to do with the contents of the textbox?

If you are getting information from the user, and want to put it in at an explicit location in a document, IMHO doing this with a userform and bookmarks is much better. This route can easily be done with no alteration of format.

You can do a lot with Word, and VBA, but it really helps to spec things out explicitly.

Macropheliac
10-10-2006, 09:00 PM
Okay. Here it is, I hope, in a nut shell.


This particular document is called a Task Safety Plan. Work crews fill them out before each job they do. Before the crew receives the T.S.P., their foreman must complete the first section (Section *(1) in the document).

Lately, there has been a problem with some of the foremen's handwriting. Therefore, I was asked if I could find a way for them to do this with their computers.

It seemed simple - just type the information with underlined text and press the delete button a number of times equal to the entry.

Well, apparantly, counting is a problem too. The result was some of the wildest looking forms I've ever seen.

I, then, decided to add textboxes and perform the underline and delete method via VBA. I thought it would be simple. After all, in Excel, this would be a 5 minute job.

Well, when I started messing with the textboxes, those "wildest forms I've ever seen" suddenly looked pretty good.

So, the point is: I need to add a textbox for each item in section *(1) of the document, transfer the text to the proper location, and keep the existing lines exactly as they are.

I have no idea of even the syntax to place text from a textbox to a particular location in a document. I feel like a major idiot.:(

I hope I have been clear. I'm sure this is a simple task for you. After 2 days, I'm completely frustrated.:banghead:

I apologise for being long. I have attached the document for reference. Once again, thank you very much for your help.

Thanks,
Mac

fumei
10-11-2006, 07:06 AM
Good heavens.....OK, I can see how this document could get out of hand. Take a deep breath.....
So, the point is: I need to add a textbox for each item in section *(1) of the document, transfer the text to the proper location, and keep the existing lines exactly as they are.May I suggest something? When you post ALWAYS try to be as explicit as possible.

Please read that quote.........

1. What is the "proper" location? I have absolutely no idea.

2. Add a textbox for each "item"....hmmmm. what do you mean precisely by item? There seems to be 10 possible entries for "Print: Crew Member". Are these the "items"? If so, will there always be 10? Is that what you mean by " keep the existing lines exactly as they are"? Is this a way to try and get the Crew members names in the document?

Again, please spec out PRECISELY, EXACTLY, what you want to happen.
It seemed simple - just type the information with underlined text and press the delete button a number of times equal to the entry.

1. Type in......where exactly?
2. Does it have to be underlined?
3. What is with the delete thing? What is it supposed to be doing????

Anyway, I had some time - from 2:00 AM to now (7:00 AM), and I put together a userform to fill in most of Section 1. Unzip the attachment and fire the form using the "Section 1 Form" icon I put on the top toolbar.

Fill it out, and press OK.

There is SOME error trapping. Try it without putting anything in the Foreman, Unit, Unit Area or Work Order fields. Or by not selecting a type - I don't know what to call those - Maintenance, Project, CUI, Turnaround. The userform displays a message in a message area, telling you what is missing. Clicking in the Foreman textbox clears the message...this could be done better....

Those Types (Maintenance, project etc.) are now checkbox Formfields. The logic on the userform determines which one to check. The user can ONLY select one...since you had "Check One" in the document. This is done by having the choices as option buttons in a frame. Option buttons in frames permit only ONE choice.

I rearranged the top of the table. It CAN be done with using overtype to insert text, but it is MUCH easier to simply inert the text into bookmarks. So Foreman, Unit etc are now bookmarks. Craft is not - I did not do that one.

Date is also not done.

This is mostly to demonstrate what can be done.

NOTE! NOTE! NOTE!



BLEEEEEECH! UGH! UGH! UGH! The horrible use of manually formatted Normal style is a real pain in the ass. If I can suggest anything that will vastly improve working with Word, it is understanding and using Styles properly.

IMHO the format of the text is awful, and not consistent.

Oh, and to be on the safe side, the file is now named Task Safety Plan_Gerry.doc

Have fun.

mdmackillop
10-11-2006, 10:56 AM
Here's a "rough and ready" solution I've used with pre-printed scanned forms when it didn't warrant recreating a complicated form.

ctengelen
10-11-2006, 01:21 PM
Hi,

I re-did just a bit of the form - using tables and TextFormFields. This way the user can enter data directly into the form. Please make sure the form is Protected before trying it out.

I hope this helps.

Trudy

fumei
10-11-2006, 05:02 PM
Wow...THREE of us send up separate documents. I'm impressed.

Macropheliac
10-11-2006, 05:39 PM
Hello Guys!
Sorry it took so long to respond.

fumei, ctengelen, and mdmackillop,
I'd like to thank you for the time and effort you put into helping me. I am very impressed.

I was able to accomplish the task after viewing some of fumei's code. Bookmarks were what I needed. I didn't know they existed until then.

I am unable to post the document, tonight, due to some server problems at work. I will, however, post it tomorrow. I would love to hear criticism.

Again, I can't tell you how I appreciate your help.

Thanks,
Mac