Quote:
Originally Posted by Guessed
Marc
I'm not sure what you mean by 'save those values to the userform'. Just by moving the control on the userform when editing the layout you are effectively saving those values.
You can use the GUI to reposition any control on the userform (assuming you can select it). You can also use a macro such as the following to position the form itself or move a control to a particular position on the form. Because of its name, this macro will autorun when the form is loading so the form will open showing your control in its rightful position.
Code:
Private Sub UserForm_Initialize()
With Me
.StartUpPosition = 0
.Left = Application.Left + 0.5 * (Application.Width - .Width)
.Top = Application.Top + 0.5 * (Application.Height - .Height)
.txHyperlinkzName.Top = 134
.txHyperlinkzName.Left = 24
.txHyperlinkzName.BackColor = &HC000&
End With
End Sub
I use this code generically on all of my userforms (apart from your control named lines) to always position my userform in the middle of the application window. This saves lots of angst when using multiple screens.
|
To answer your question, Andrew, even though the encircled VBA code (on the right side of the image below) did set "txHypterlinkzName" in the location encircled in blue below on the userform, "txHypterlinkzName" would not be in that location later when I was editing the userform (i.e., dragging controls from one place to another).
In other words, after I ran the Initialize sub and subsequently closed the userform (after showing it), "txHypterlinkzName" would return to a location off the screen, which made it hard to continue editing the userform.
Graham's instructions enabled me to get to txHypterlinkzName's Properties Window (encircled in green in the attached image file, to the left).
Once I got access to txHypterlinkzName's Properties Window, I was able to manually insert the settings that are encircled in red, below to the left, inside the green box.
After I inserted those settings, I executed a Windows/Word [File, Save] on the form.
Now, when I am editing the userform, "txHypterlinkzName" continues to be situated at the location encircled in blue below.
It would be nice to know how to use vba to perform the equivalent of me manually inserting the settings in the properties window, and thereafter clicking, File, Save.
You showed me how to get and set the controls' coordinates programmatically, which was very helpful to me.
But assume that I have a large userform with many controls that need to be renamed (instead of having their coordinates changed) programmatically (which is a problem I remember having more than once), it would be nice to know how to save the changes to the form, so that the changes are embedded in the form when I resume editing the form.
Much thanks, again,
Marc