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" oreferrelative="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> <vath o:connecttype="rect" gradientshapeok="t" o:extrusionok="f"> <o:lock aspectratio="t" v:ext="edit"></o:lock></vath></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">
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" oreferrelative="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> <vath o:connecttype="rect" gradientshapeok="t" o:extrusionok="f"> <o:lock aspectratio="t" v:ext="edit"></o:lock></vath></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
Any help would be greatly appreciated. Thanks
</v:imagedata></v:shape>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
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