[RESOLVED] VB in Ms Word. Input form user?
Hi
Im working on a litte macro (in a toolbar) in Ms Word where i need some input from the user (perhaps in a textbox). I know how to write "regular" code: manipulating variables, msgboxes and so on. But since there is no form or similar when i edit the macro, how do i create controls and get input from the user? Can i create a form, or is there some dialog box i could show?
This is my first attempt at writing something for word
Edit:
The actual application is: User klicks toolbar button - user enters stuff into textboxes, dropsowns etc - document is saved to a place depending on input
Re: VB in Ms Word. Input form user?
Thread moved to Office Development forum
Re: VB in Ms Word. Input form user?
the simplest way is to use an inputbox
vb Code:
result = inputbox("enter data here")
the arguments include the default return
as you want to save the document, the best option is to show the save dialog
vb Code:
Application.Dialogs(wdDialogFileSaveAs).Show
Re: VB in Ms Word. Input form user?
Thanks for the reply, i am aware of the inputbox but what i was looking for was some more advanced input controls, such as dropdowns, checkboxes and such, is it possible to do this? Or is a possible sulution to write a separate program that is executed from my toolbar button, with variables passed to it that can save the document? Im not looking for a complete solution from anyone but perhaps pointers to what possibilites there are. Thank you!
Re: VB in Ms Word. Input form user?
Quote:
Originally Posted by zappbrannigan
Thanks for the reply, i am aware of the inputbox but what i was looking for was some more advanced input controls, such as dropdowns, checkboxes and such, is it possible to do this? Or is a possible sulution to write a separate program that is executed from my toolbar button, with variables passed to it that can save the document? Im not looking for a complete solution from anyone but perhaps pointers to what possibilites there are. Thank you!
yes it is possible.
1) Click on Menu View=>Toolbars=>Control Toolbox
2) insert a commanbutton in the sheet
3) Double click on the commandbutton to open the code window
4) type this there
Private Sub CommandButton1_Click()
UserForm1.Show
End Sub
5) right click on the "ThisDocument" on the right hand side under the projects window and insert a userform. name this userform "Userform1". On this userform you can place your controls
6) Go back to the word document and exit from design mode
7) click on the button, the userform will appear :)
Hope this is what you wanted?
Re: VB in Ms Word. Input form user?
yes! i ended up doing it this way: added the userform to normal.dot instead and used a toolbar button for the userform1.show() instead
Thank you