Solved

Microsoft Word Pop Up Form

Posted on 2016-10-25
7
73 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
[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
  • 3
7 Comments
 
LVL 18

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

 

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 18

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 18

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Introduction This tutorial provides instructions on how to properly format your Word document using the inbuilt tools provided. The benefits of using these tools means your documents are more accessible and easily portable to other applications an…
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 walks the viewer through the process of creating an MLA formatted document, as well as a bibliography with citations.
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.

739 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