Solved

Word 2010 Form - pop up questions

Posted on 2013-01-08
6
825 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 39

Assisted Solution

by:als315
als315 earned 150 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 76

Expert Comment

by:GrahamSkan
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks very much for your help on this - works perfectly
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

If you work with Word a lot, you probably use styles. If you use styles a lot, you've probably balled your fist more often than not when working with the ribbon. In Word 2007/2010, one of the things that I find missing when using styles is a quic…
This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now