Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

placing userforms in Word 1

Status
Not open for further replies.

NevilleBacon

Technical User
May 16, 2005
3
US
When I enter certain paragraph styles and begin typing, I'd like a UserForm to appear below that line with a choice of inputs in a listbox(the code for which I've already worked out).

I just don't know how to get the Userform to appear at the selection point, or more precisely one line below it, so that users can see the choices, double click the text they want, or continue typing and the text is completed/updated as they type. The main thing is the form placement.

Anyone have any ideas?
 
Please spec this out a little better.

1. "I enter certain paragraph styles". i am very unclear what this means. "Enter" a paragraph style????

2. What are the choices in the list??

3. " the text is completed/updated as they type" Huh? Are you not betetr using AutoText?

Not that I am trying to suggest NOT using a UserForm - but what exactly are you trying to do? UserForms take up resources; they slow things down in terms of user interaction with a document. Often they are needed, or very useful, and therefore that supercedes the distraction of a userForm. So, OK, WHAT is on this list?

I know you are asking more about placing the form precidely, and with some reasonably tricky effort, this could be done, but WHY?

Gerry
See my Paintings and Sculpture
 
Yeah, all I'm really looking for is how to place the userform. Everything else is just background.

Autotext will not update the text realtime (it responds after the field is exited). And I don't want that.

Entering a style would happen in the event that the style were already created for a certain paragraph and a user happens to place focus within it. For instance they go back in the document and decide to change the text on a certain line that they had previously typed.

Or when a certain paragraph style is exited using tab or enter, the following style is dictated by the manner the user exited the last style. Press enter, style one. Press Tab, style two.

Again, I'm really just looking for how to place the form. even at the bare minimum what is the function, keyword, whatever that handles the coordinates? And how do I read the coordinates of the selection?
 
Why not simply use the InputBox function ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi Neville,

The 'background' is fascinating. How are you going to trigger the display? What are you monitoring?

To place a Userform. Show it non-modally (needs Word 2K at least) and then set the Top and Left properties - it will probably show in its initial place and jump.

To determine the cursor position look at Selection.Information (wdVerticalPositionRelativeToPage) (and wdHorizontaletc). You'll also need to look at the View (and possibly Zoom, I'm not sure)

It won't be easy. Good luck!

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
Tony,

FYI your comment
To place a Userform. Show it non-modally (needs Word 2K at least) and then set the Top and Left properties - [highlight]it will probably show in its initial place and jump.[/highlight]

If you set the Userform's StartupPosition property to Manual (0) in conjunction with its Left & Top properties, the form will appear in the specified location.


Regards,
Mike
 
Thanks, Mike.

Something I learnt today so a star from me.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
Yes, it will. Which was my point that it CAN be done, but I am still confused as to design and purpose.

1. "Or when a certain paragraph style is exited using tab or enter, the following style is dictated by the manner the user exited the last style. Press enter, style one. Press Tab, style two."

Pray tell...how are you going to do that? You would have to have something constantly running in the background. and what, I am dying to know, and I am serious...I really want to know - how are you determining an "exit". You are going to monitor key presses? So if the Enter key is pressed - Do This, and if the Tab key is pressed - Do That?

What if they just need a tab? As Tony asked - how are you going to trigger the display?

2. "Entering a style would happen in the event that the style were already created for a certain paragraph and a user happens to place focus within it. " How are you getting your code to recognize "focus" to ANY paragraph?

Again, I suppose you could have a running piece of code that constantly checks whatever style the Selection point is in. But it would have to be constantly running.

"in the event that the style were already created for a certain paragraph". Interesting statement. It is literally impossible to have a paragraph WITHOUT a style. Every paragraph has a style.

I am not trying to be difficult. I like to learn things, and I am very interested in design. Could you elaborate on what you are doing? I really want to know.

Regarding The information above vis-a-vis the starting location:

1. yes, you can make the UserForm start up anywhere you like.

2. yes, you can use Selection.Information to get the location of the Selection.

3. That information does NOT take into account the menubars (do you have three lines of menus, two?, one?) as the information is all relative to either the page, or the text.
Code:
Sub UserForm_Initialize()
UserForm1.Left = _
    Selection.Information(wdHorizontalPositionRelativeToPage)
UserForm1.Top = _
    Selection.Information(wdHorizontalPositionRelativeToPage) + 100
End Sub
The UserForm is SystemModal = False, StartUpPosition is manual. I added 100 to bring the form below the Selection point. However, depending on how you have the document displayed, you get unruly results.

Again, please let me know what it is you are doing. I am quite curious.

Gerry
See my Paintings and Sculpture
 
Thanks to everyone.

Fumei, I may not answer all of the questions. The purpose is so that a user can have access to what they've already entered in previous paragraphs of the same style and they won't have re-type. As they type the closest match will fill in (or they can use the listbox on the userform (which I don't think I mentioned) and scroll to the text they want, though hitting the first few keys will be convenient), text on the page will be updating as they type realtime.

Also: bear in mind these special types of paragraphs will have limited text entry. They are not going to be filling these pragraphs with prose, simply one or two word entries, which will change from user to user.

For instance say that Sand is in the list from previous paragraphs of certain style created by the user entering the line with a certain key, and it is the only "S" word in the list so far. Let's say the user wants to type "Sand". As he types S the form with list box will pop-up just below the selection point and Sand will be selected in the list and will also be appearing in grayed typeface on the page. The user can then hit enter or tab, the selection becomes black typeface, and user moves on. Or if they want to enter a different text they type it in, and the next time they type S in that style of paragraph line they will then have the choice of two S words, which will update the selection as they type the second key. So if we have Sand and Skin in the list, once the k is typed Skin becomes the selection in the list and the grayed text on the page. User hits enter. Text black, user goes to another paragraph.

I've already got it working a little, but it's still buggy. Also, yes, I'm monitoring keypresses with keybindings set for my tab, enter, period, colon, open paren, close paren, arrow keys, shift, ctrl, alt, and backspace keys so far. I dont' see any other way than to bind the entire keyboard eventually. It doesn't have to perform like a monkey on speed, it just has to work. Though a monkey on speed type performance is what I'm shooting for.

With all keys bound that may be the only monitoring that I'll need. Except for when the user leaves a paragraph without typing any text. Since they can move the selection with the mouse, the mouse may need to be monitored, but I'm not worrying too much about that.

Yes, every paragraph has a style, but I'm talking about custom styles.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top