Solved

Word 2010 Form - pop up questions

Posted on 2013-01-08
6
949 Views
Last Modified: 2013-01-09
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!
0
Comment
Question by:correlate
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 40

Assisted Solution

by:als315
als315 earned 150 total points
ID: 38755029
You can add module (Press Alt+F11, Insert-Module from menu) to your document and put AutoOpen sub to this module:
Sub AutoOpen()
   'here should be some code
   MsgBox "Enter something", vbOKOnly
End Sub

You should save document as Macro enabled (docm). Your users should allow macro to run (it also could be a problem).
AutoOpen sub fill fire when you open document. Look at sample (rename to doc1.docm)
Doc1.docx
0
 

Author Comment

by:correlate
ID: 38755272
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?
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 38755402
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

0
[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

 
LVL 76

Expert Comment

by:GrahamSkan
ID: 38755418
You need

Enter_Details.Show to open a UserForm

DoCmd is not meaningful in Word
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 350 total points
ID: 38755448
This would load the text from a couple of text boxes on the Userform into Content controls with their tag properties set to match

Private Sub CommandButton1_Click()
    FillCC txtFirstName.Text, "FirstName", ActiveDocument
    FillCC txtFirstName.Text, "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
0
 

Author Closing Comment

by:correlate
ID: 38759482
Thanks very much for your help on this - works perfectly
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Shortcuts in Word Just the other day I had a training for Microsoft and they wanted me to show how well the new Windows and Office behaved on a touch device, which by the way is great, but it was only then that I realized that using keyboard shortc…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question