Solved

Microsoft Word Pop Up Form

Posted on 2016-10-25
7
34 Views
Last Modified: 2016-10-25
I have several tables in a Word document.  Within each table, I have a designated cell for configuring a reporting function.
The contents of the cell is a delimited string full of configuration information.

Example:     name1=value1~name2=value2~name3=value3, etc

I would like the user to be able to double click or some other action to yield a pop up form that would present an input box for each name value pair allowing them to edit the cell through the pop up.

Any suggestions on approach to do this appreciated.
0
Comment
Question by:maxdbase
  • 3
  • 3
7 Comments
 
LVL 17

Expert Comment

by:xtermie
ID: 41858470
You can add a Fill-in field in the cell you want, and even have a field prompt
You would have to give an initial value and then the field would popup once you either
a) right click and select update
or
b) press F9

In Quick Parts (Insert ribbon) select Field and you will find the fill-in
You can check more fields, as you may find something more appropriate
0
 

Author Comment

by:maxdbase
ID: 41858487
Screenshot:  
http://www.screencast.com/t/5ahbpAzrHgzV

Yes, if I could have the prompt be multiple fields and then map back to the cell that would do it.
0
 

Author Comment

by:maxdbase
ID: 41858499
The Macro seems to be able to allow for a pop up like this:

http://www.screencast.com/t/FdJ5KjO3Z9w8

I would need to open the pop up from the cell.  How do that?

Then map the fields back to the cell.  Assume that would be a vba thing linked to a button
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:maxdbase
ID: 41858521
http://www.screencast.com/t/0u2coPfzCqRY

The above is pretty close, I just need to be able to identify the selected cell in the vba then map the contents
of the form fields back to that cell.  Any sample code to do this will answer the question.
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 41858548
In VBA it isn't possible to hook mouse actions over the document, so It would be better to run a macro from a QAT button and/or a shortcut keystroke. The macro would show the Userform.

Code in the userform's Initialize event could capture the text and display it in text boxes. If there are likely to be quite a few items, you could use a listbox and have some code to copy the seleted line into two text boxes for editing.

Let us know if you need any further advice on the code.
0
 
LVL 17

Expert Comment

by:xtermie
ID: 41858617
To create a table from an Excel file, you must either create an Excel file or use one you already have and change the path in the code to point to it.
To insert this field using the Word object model, use the Fields.Add method:

Sub Test
    Dim rng as Word.Range
    Dim xlRange as String
    xlRange = "Sheet1!R12C1:R18C3"
    Set rng = Selection.Range
    ' Note that backslashes in field paths must be doubled.
    LinkTable rng, "C:\\test\\yourExcelFile.xls", xlRange, "\h"
End Sub
Sub LinkTable(rng As Word.Range, path As String, _
    xlRange As String, linkFormat As String)
  
    Dim fieldText As String
    Dim fld As Word.Field
    
    fieldText = "Excel.Sheet.8 " & Chr$(34) & path _
        & Chr$(34) & " " & Chr$(34) & xlRange & Chr$(34) _
            & linkFormat
    ' Insert the field code as text.
    rng.Text = fieldText & vbCr
    rng.Collapse Direction:=wdCollapseEnd
    ' Insert the linked table.
    Set fld = rng.Fields.Add(Range:=rng, Type:=wdFieldLink, _
        Text:=fieldText, PreserveFormatting:=True)
    Set rng = fld.Result
    rng.Collapse Direction:=wdCollapseEnd
End Sub

Open in new window

0
 
LVL 17

Expert Comment

by:xtermie
ID: 41858619
Another option, simpler, if you want to add specific cell data into specific cells in the Word table is to create a mail merge document.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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 2010 Conditional Printing 11 61
add bookmark label to 78 documents 2 54
Word / Printing 8 59
How to customise Office 2016 font settings with a GPO 3 83
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…
Nice table. Huge mess. Maybe this was something you created way back before you figured out tabs or a document you received from someone else. Either way, using the spacebar to separate the columns resulted in a mess. Trying to convert text to t…
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.
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.

863 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

25 Experts available now in Live!

Get 1:1 Help Now