Link to home
Start Free TrialLog in
Avatar of Tom Crowfoot
Tom CrowfootFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Word 2010 Form - pop up questions

Dear Experts

I am trying to create a word document which users fill in when its opened - basically the document is our standard terms of business which requires a few fields filled in (such as client name, salesman's name, a date etc)

So when a user opens the document I want a pop up box to appear where the user answers a few questions (client name, salesman's name, a date etc). Once they have done this the fields are updated with their answers and the document is done!.

I have put in the content controls but cannot seem to find a way of setting up the pop up box & getting it to fill out the details

Can anyone help -I'm a bit basic on Word!
SOLUTION
Avatar of als315
als315
Flag of Russian Federation image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Tom Crowfoot

ASKER

Hi thanks for that

I have built the basis of the form & called it "Enter_Details", but cannot seem to get it to open

Sub AutoOpen()
DoCmd.OpenForm "Enter_Details"
End Sub

Open in new window


Also I have no real idea how the data gets from the form into the document?

Can you help?
You can change each Content Control's static prompt in Design Mode.

Otherwise you could employ some VBA.

The simplest would be a series of InputBox statements, but unless there are a very few, that could get unwieldy and likely to annoy anyone trying to use it. The code would go into a code module in the document's template.
Sub InputBoxes()
    Dim strText As String
    
    strText = InputBox("First Name")
    FillCC strText, "FirstName", ActiveDocument
    strText = InputBox("Last Name")
    FillCC strText, "LastName", ActiveDocument
End Sub

Sub FillCC(strText As String, strTag As String, doc As Document)
    Dim ccs As ContentControls
    Set ccs = doc.SelectContentControlsByTag(strTag)
    ccs(1).Range.Text = strText
End Sub

Open in new window


The code would be called from the Document_New and the Document_Open Subs in the ThisDocument module of the template.
Private Sub Document_New()
    InputBoxes
End Sub

Private Sub Document_Open()
    InputBoxes
End Sub

Open in new window

You need

Enter_Details.Show to open a UserForm

DoCmd is not meaningful in Word
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks very much for your help on this - works perfectly