PDA

View Full Version : Keeping a userform from blocking the selection.



BoatwrenchV8
08-17-2013, 02:02 PM
Does anyone know of a way to prevent a userform from obscuring the selection in a document? Is there away to move the userform based on the location of the selection?

fumei
08-17-2013, 10:13 PM
Yes, but not easily as the Selection can be anywhere. What exactly is the problem, as you CAN easily just move the userform to wherever you want.

BoatwrenchV8
08-18-2013, 02:09 PM
I have a macro that looks for dates, numbers with units and a few other things by using a wildcard search. There are a total of 11 wildcard searches in my macro and more will be added. When each instance is found, a message box pops up asking if I want to replace, find next or quit. The message box pops up in the center of the screen and is usually in the way. I figured I would replace the message box with a userform that I can programmically move out of the way from the current selection, so the selection is not hidden behind the userform. The userform would simply have 3 buttons: Replace, Find Next and Quit. A while ago and a few computers ago, I thought I found code that will do that in Word but I cannot find it now and do not remember how it worked.

The idea I had was to determine the location of the selection by using the information properties of the selection, then figuring out what part of the document is visible and move the userform somewhere that the entire userform is visible and is not blocking the selection.

Word would be running maximized, with the ribbon showing. This would be used in Word 2007 - Word 2013, possibly also 2003 too.