Solved

Microsoft Word Pop Up Form

Posted on 2016-10-25
7
24 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
Preface: When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
This video walks the viewer through the process of creating a watermark for their document, customizing it, and saving it for viewing/printing needs.
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…

747 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

12 Experts available now in Live!

Get 1:1 Help Now