PDA

View Full Version : Solved: Select location within word doc



mvidas
01-11-2006, 12:04 PM
Hi everyone,

I am working on something that deals with excel and word together.. I'm taking text from a user-specified cell in excel, and pasting it into word.

I have it all set, with one minor question:

Is there a way for me to prompt the user for a location within the word doc to paste the text?

My algorithm is as follows:
'Select cell in excel to paste to word
'choose word file to open
'open word file
'NEEDED: CHOOSE LOCATION TO PASTE INTO
'enter cell text into word using selection.typeparagraph and selection.typetext

As you can see, I'm trying to figure out a way to have the user select a location, everything else is working just fine.

Any help?
Matt

Jacob Hilderbrand
01-11-2006, 12:27 PM
Try using a User Form to show you message. When you show the User Form make it Modeless.

UserForm1.Show False

Then the user can select the document and move around to the right spot, then click a button on the User Form that will Unload it.

So the macro would pause while the User Form is shown, once it is gone the macro will continue.

mvidas
01-11-2006, 12:46 PM
Not a bad idea.. then again I could even just use a msgbox in excel to have the user do that. This isn't actually for me, so I'm going to pass the idea along. I wasn't sure if word had it's own application.inputbox or any propietary msgbox or anything.. :)
Thanks Jake

Jacob Hilderbrand
01-11-2006, 01:32 PM
You're Welcome :beerchug:

fumei
01-12-2006, 07:12 AM
Just in case anyone else may be interested, the attached file demonstrates this.

You may activate it with the keyboard shortcut of Alt-i.

This fires an Inputbox to get some test text. Obviously if this was coming from another procedure you can simply use whatever string you want from that.

The string variable has to be public to be able to pass between the procedure in the module, and the procedures in the UserForm.

In any case, after the test string is received from the Inputbox, the UserForm appears. It has SystemModal as False, so it can be moved. Once a location is selected, the command button that does the insertion switches to "Undo?". This way if the users want to change their mind as to the location, it is easy for them to go back. Selecting the OK - Done button accepts user action and unloads the form.

The form can just as easily take a string variable from Excel.

mvidas
01-12-2006, 07:42 AM
Hi Gerry,

That is exactly what I was looking for (and what Jake described above), I was just hoping word had something similar built in.. The macro in excel is actually opening a user-specified word file and inserting it that way, so I couldn't add a word form, even to the normal.dot (since there could be many end-users). Truth be told, I ended up just using a plain ol' msgbox in excel stating to move the cursor in word to the desired location. The modeless thing didn't matter, since it was one app to another.

In any case, good code there, perfect example of what I was looking to do :thumb