Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Word 2010 Form - pop up questions

Posted on 2013-01-08
6
Medium Priority
?
998 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 600 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] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

 
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 1400 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

I would like to show you some basics you can do with Mailings in MS Word. It´s quite handy feature you can use for creating envelopes, labels, personalized letters etc. First question could be what is this feature good for? Mailing can really he…
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…
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…

972 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