Link to home
Start Free TrialLog in
Avatar of Harsh Kumar
Harsh KumarFlag for Denmark

asked on

VBA Word Userform call again with button if changes in the content

Hi guys,

I'm trying to figure out a way to recall the userform if there is some changes in the textboxes (typo's)

I found out how to call the userform with this code:

Private Sub Menu_Click()

UserForm.Show

End Sub

Open in new window


but when i make the changes and push ok it does not change the text but add's it to the current text.... is there a way to call it correctly?
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

To be clear about what you are asking.

I suppose that you have a UserForm set up so that when the user presses the 'OK' button, it loads data from the UserForm text boxes on to the document.

You now need a way for the user to open the UserForm again and repeat the process because he has noticed an error in the 'downloaded' text.

You must already have a macro to open the UserForm so select the dropdown arrow at the right of the Quick Access Toolbar (on the left of Word window's title bar). Choose 'More Commands..'  and  then 'Macros' in the top left-hand box of the 'Word Options' window. Find your macro, and move it across to the right-hand list with the 'Add' button. 'OK' the window away and you should have a new QAT button to open the UserForm again
Avatar of Harsh Kumar

ASKER

Hi GrahamSkan,

Thank you for your reply,

it is correctly understood that the userform will insert the data, and i want to repeat the process :)

that was the first thing i tried since it should work but i cant seem to get what i'm doing wrong since the code is not there... :S

have a look:

User generated image
You are looking in the Normal template (the right-hand combo has 'For all documents' selected). You will need to choose your custom template from that list.
ahhhh right.. SORRRY!!! my bad!! DOH! thank you for being soo patient with me im really trying to learn here, thank you sooo much for all the help!

That said I have no idea what i'm doing wrong for some reason the macro does not show.... i have tried to make a new module and make a call on it but it does not pop up on the list... am i doing something thing wrong? (obvisouly) hehe

i'm abit fustrated now....
Sorry,
The previous advice I gave you refers to which template is to have the button.

The reason that your macro does not appear is that the procedure is 'Private'. Remove that word or replace the word with Public, and you should see the macro in the left-hand list.

This begs the question of 'how do you run the macro in the first place?'
The button is working now, although the text that is already inserted does not get removed... is there a way to clear the content that was inserted at the bookmarks earlier??
ASKER CERTIFIED SOLUTION
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Okay, makes sense! thank you explaining its so well specially for me as a newbie, i'm still learning :)

I havn't writtin it like as you have states and the bookmarks does not get deleted they stay where they should be..  this is how i have coded the bookmarks ref.

ActiveDocument.Bookmarks("momfrad").Select
Selection.TypeText Text:=Me.txtmomfrad

Open in new window


with the code you have states above, will i need to type in all the bookmarks in the code again or how??

I'm sooo fustrated!!!! arrrrrrggghhh!!!!! almost giving up on VBA!
I'm afraid you will. It's a part of the learning process.
I have been trying to work out a way of doing a find and replace, but it's a bit too complicated for that.
Thank you sooo much for your patience and time! you rock!!!!

i will try to have another look at it in a few days... i'm even speaking VB'ish in my sleeep these days lol!