Solved

Word 2010 Form - pop up questions

Posted on 2013-01-08
6
870 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
  • 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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.

 
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
Microsoft Word Pop Up Form 7 51
add more styles to my code 2 51
Help with Word VBA class module 4 58
How to hyperlink a document in MS Word w/o full path 1 35
Preface: When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
Microsoft Word is a program we have all encountered at some point, but very few of us have dug deep into its full scope of features, let alone customized it to suit our needs. Luckily making the ribbon (aka toolbar, first introduced in Word 2007) wo…
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
This Micro Tutorial well show you how to find and replace special characters in Microsoft Word. This is similar to carriage returns to convert columns of values from Microsoft Excel into comma separated lists.

792 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