Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-04-2017, 08:41 PM
rx360 rx360 is offline Creating a Form Which has Multiple PrePopulated Forms Within Windows 10 Creating a Form Which has Multiple PrePopulated Forms Within Office 2016
Novice
Creating a Form Which has Multiple PrePopulated Forms Within
 
Join Date: Dec 2017
Posts: 2
rx360 is on a distinguished road
Question Creating a Form Which has Multiple PrePopulated Forms Within

Hello,

I am looking to create a fairly simple form. I would like the document to have 2 or 3 prepopulated forms. It should be preceded with the variables that need to be replaced within the forms, and then a check list at the bottom where the user can select the form they would like to be generated:

Name
Address

_ Form 1
_ Form 2
_ Form 3



Once the name and address are filled in, the user selects the form they want and it the form should pop up with all the variables filled in.

What functionalities of Word/VBA am I looking at using here to accomplish this?

Thank you for your help!
Reply With Quote
  #2  
Old 12-05-2017, 01:47 AM
gmayor's Avatar
gmayor gmayor is offline Creating a Form Which has Multiple PrePopulated Forms Within Windows 10 Creating a Form Which has Multiple PrePopulated Forms Within Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

So not a simple form at all? The common sense approach would be simply to have three forms, but who is going to be completing this form?

if you want the form contents all to be contained in a single form then you will need to create a template to contain the macro code and the three alternative 'forms' as autotext entries.

You would then need a bookmark in the body of the template to take the autotext content.

Create a userform to gather the data and the form choice and then a pair of macros to apply the required autotext entry to the bookmark and to write the data collected to bookmarks contained in the inserted autotext entries. e.g. as follows. This only has one data bookmark. You can have as many as you need and call the function for each. If the bookmark doesn't exist the macro to fill that bookmark doesn't do anything.

Code:
Sub AutoTextToBM(strbmName As String, oTemplate As Template, strAutotext As String)
'strBMName is the name of the bookmark to fill
'oTemplate is the template with the autotext - probably ActiveDocument.AttachedTemplate
'strAutotext is the name of the autotext entry
Dim orng As Range
    With ActiveDocument
        Set orng = .Bookmarks(strbmName).Range
        Set orng = oTemplate.AutoTextEntries(strAutotext).Insert _
                   (Where:=orng, RichText:=True)
        .Bookmarks.Add Name:=strbmName, Range:=orng
    End With
lbl_Exit:
    Exit Sub
End Sub

Public Sub FillBM(strbmName As String, strValue As String)
'Graham Mayor - http://www.gmayor.com
Dim orng As Range
    With ActiveDocument
        On Error GoTo lbl_Exit
        Set orng = .Bookmarks(strbmName).Range
        orng.Text = strValue
        orng.Bookmarks.Add strbmName
    End With
lbl_Exit:
    Set orng = Nothing
    Exit Sub
End Sub
At its very simplest see the attached template which contains a simple userform, three autotexts and the above macros. Create a new document from the template and make some choices.
Attached Files
File Type: dotm Form Example.dotm (41.0 KB, 12 views)
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 12-05-2017, 06:45 PM
rx360 rx360 is offline Creating a Form Which has Multiple PrePopulated Forms Within Windows 10 Creating a Form Which has Multiple PrePopulated Forms Within Office 2016
Novice
Creating a Form Which has Multiple PrePopulated Forms Within
 
Join Date: Dec 2017
Posts: 2
rx360 is on a distinguished road
Default

Thank you for the reply. This helps quite a bit, a bit more complex than what I expected the solution to be, but nonetheless, doable, thank you very much.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook 2013 Forms (how to questions)- Quick opening of a form file & Linking form's data to Excel gamin2407 Outlook 0 01-21-2017 10:14 PM
To Box is Prepopulated Learn2010 Outlook 0 02-12-2016 08:20 AM
Creating a Form Which has Multiple PrePopulated Forms Within Creating Forms DLee-AB Word 2 02-08-2016 03:30 PM
Creating Forms for users to complete dalaurienzo Word 1 07-19-2010 04:12 PM
creating forms on word 2007 Incasa Word 2 04-28-2009 10:47 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:56 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft