|
-
Feb 4th, 2008, 08:30 AM
#1
Thread Starter
New Member
[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
Last edited by zappbrannigan; Feb 4th, 2008 at 08:56 AM.
-
Feb 4th, 2008, 01:06 PM
#2
Re: VB in Ms Word. Input form user?
Thread moved to Office Development forum
-
Feb 5th, 2008, 03:27 AM
#3
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Feb 25th, 2008, 09:13 AM
#4
Thread Starter
New Member
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!
-
Feb 25th, 2008, 09:24 AM
#5
Re: VB in Ms Word. Input form user?
 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?
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Feb 26th, 2008, 04:54 AM
#6
Thread Starter
New Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|