Is it possible to set up a form in Word VBA so that when the form pops up, it is over to the right of the screen, allowing users to see a bit more of what is on their page before making their selections on the form?
You can set the Left and Top properties of the userform. This can be done on initializing of the form, or done programmatically by user action (i.e. you can move the form out of the way by some user action), or done programmatically based on some internal logic/event.
You could also make the form shrink to a wee little thing while the user looks at the document, then they could click it back to full size. If you do not make the form modal, then they could simply move it around themselves.
Make the ShowModal property of the UserForm = False. This allows the focus to be moved to the document. The user can move around and edit.
To resize, what I do is have a Label across the top of the form, The caption is "Shrink / Expand". On the Label_Click event I put position and sizing instructions.
Say the fully open form is: Height = 130, Width = 300, Top = 200, Left = 200. The following toggles between fully displayed, and shrunk and moved to the top of the screen.
Sub Label_Click ()
If Me.Height = 130 Then
With Me ' shrink form and place at top of screen
.Height = 22
.Width = 100
.Top = 0
.Left = 250
End With
Else
With Me ' expand form to position
.Height = 130
.Width = 300
.Top = 200
.Left = 200
End With
End If
End Sub
Just make sure you keep enough of the actual form visible in the smaller size! It is possible using API to have a click title bar event, but there is no easy way in VBA. Clicking the title bar will not fire the resizing event. At least a small part of the form has to be visible - in that part is my label, so it can be clicked.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.