UserForm help

rholdren

Board Regular
Joined
Aug 25, 2016
Messages
140
Office Version
  1. 365
  2. 2019
I’ve been searching the forums for a while but cant quite find a thread quite like this problem. I’ve used VB and Excel for a long time but believe it or not this is my first time using a Form. I had been trying to find if there was a way to have a single message box that provides three inputs but struck out so I went with the following code to open a document based on the user input in the three boxes.

Sub Locate_Retrieve ()
Dim GroupName As Variant
Dim PlanName As Variant
Dim PlanYear As Variant

GroupName=InputBox(“Enter Group Name:”)
PlanName = InputBox("Enter Plan Name:")
PlanYear = InputBox("Enter Plan Year:")

Range("B2").Value = PlanName
Range("B3").Value = PlanYear

If GroupName=”MDC” and PlanName=”LIMITED HDHP PLAN” and PlanYear=”2017” then
Call MDC_2017LIMITED
End sub



This works fine but I was asked to streamline and see if I could provide a singe source of input, like a User Form. I came up with the idea a user form that allows the input but not sure how to put it together. What I would like to do is have the user input data in TextBox1 replace GroupName(InputBox), TextBox2 replace PlanName(InputBox), and TextBox3 replace PlanYear(InputBox) )the three smaller boxes) and the result, which is a word document, would open in TextBox4 (the big box on the right side) instead of just lanunching Word and opening the document.




<v:shapetype id="_x0000_t75" stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t" o:spt="75" coordsize="21600,21600"> <v:stroke joinstyle="miter"> <v:formulas> <v:f eqn="if lineDrawn pixelLineWidth 0"> <v:f eqn="sum @0 1 0"> <v:f eqn="sum 0 0 @1"> <v:f eqn="prod @2 1 2"> <v:f eqn="prod @3 21600 pixelWidth"> <v:f eqn="prod @3 21600 pixelHeight"> <v:f eqn="sum @0 0 1"> <v:f eqn="prod @6 1 2"> <v:f eqn="prod @7 21600 pixelWidth"> <v:f eqn="sum @8 21600 0"> <v:f eqn="prod @7 21600 pixelHeight"> <v:f eqn="sum @10 21600 0"> </v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:formulas> <v:path o:connecttype="rect" gradientshapeok="t" o:extrusionok="f"> <o:lock aspectratio="t" v:ext="edit"></o:lock></v:path></v:stroke></v:shapetype><v:shape id="Picture_x0020_2" style="width: 468.75pt; height: 263.25pt;" type="#_x0000_t75" alt="" o:spid="_x0000_i1025"> <v:imagedata o:href="cid:image003.jpg@01D32E08.12CD5920" src="file:///C:\Users\rholdren\AppData\Local\Temp\4\msohtmlclip1\01\clip_image001.jpg">
I know the code above works with message boxes but how do I replace the InputBox of the macros to the TextBox of the user form and get the results to open in TextBox4

the Call program just goes to the file location and opens the doctument (this is what I want to appear in tTextBox4
Sub CRP3D_PLANA()


Dim objWord


Dim objDoc


Set objWord = CreateObject("Word.Application")


Set objDoc = objWord.Documents.Open("X:\Intranet\Client Listing\HSB\3D Corporate Solutions\Benefits\MYPLANDOC Plan A.docx", ReadOnly:=True)


objWord.Visible = True​


Any help would be greatly appreciated. Thanks
</v:imagedata>
</v:shape>
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
I'm afraid you can't open a Word document in a textbox.

The closest you could get to something like that I think would be to use a WebBrowser control.

Why don't you want to open the document in Word?

What will the user be doing with the document?
 
Upvote 0
I can get it to open the word doc but was just trying to streamline. Our office has a lot of people with a lot of windows open at the same time and this can slow the system at times. They way I designed the form would allow the user access to the same information but without opening six addition windows. Multiply that over 100+ users and that's a little of resources saved and stress reducer on the system.

How do I get the values in the textbox to be read like the values in the message box?
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top