Solved

Word 2010 Form - pop up questions

Posted on 2013-01-08
6
887 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Suggested Solutions

Title # Comments Views Activity
Convert .PDF 6 78
Office 365 home questions 7 88
Word 2016: VBA code Style Source checkbox in Reveal Formatting Pane 3 60
delete blank pages by means of VBA 10 31
When creating Microsoft Word-based forms there may be a need to have a form field repeated throughout the whole document. For instance, with a company name, you may want this information repeated automatically throughout the document rather than man…
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 shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…

733 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