Link to home
Start Free TrialLog in
Avatar of Keith McElroy
Keith McElroy

asked on

Microsoft Word Pop Up Form

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.
Avatar of Anastasia D. Gavanas
Anastasia D. Gavanas
Flag of Greece image

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
Avatar of Keith McElroy
Keith McElroy

ASKER

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.
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
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.
ASKER CERTIFIED SOLUTION
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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

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.