PDA

View Full Version : VBA form



Vnswamy
07-11-2011, 12:21 PM
Hello all,

I am building a form in word. One section needs to take certain sections of the form and turn it into a list. So for example, the list may be sections 1, 2, 4, and 6. I'd like this to happen by the user clicking a button "submit". Any ideas how to do this?

Thanks!

gmaxey
07-11-2011, 04:34 PM
Getting help, at least from this quarter, is going to require a better description of your objective. "One section." A Word document is a little like Russian dolls; characters fit into words, words fit into sentences, sentences fit into paragraphs, paragraphs fit into sections, sections fit into documents. Does that mean one section of a Word document or just a part of your form?

Vnswamy
07-12-2011, 08:30 AM
Thanks for the response!

So to be more specific this is what I want with an example below:

1. A word file with 5 tables
2. A button that says "submit"
3. When the "submit" button is pressed, one of the tables will fill with certain words. These words are certain sections of the tables from requirement 1.

Here is a portion of the form, The "tags" section is what I want to automatically be filled out when somebody presses "submit"

Owner
Joe JohnsonFile(s)
Ppt, xls, pdf
Location
Chicago
Most Recent Update
07/08/2011


Date Submitted
02/08/2011

Description

Category

Training, Notes, Participant, Assessment,

Name

Training

Audience

New Hires

Course Objective

To train new hires in management skills

Delivery Method

Informational session

Tags

Joe Johnson, Ppt, xls, pdf, Chicago, Training, Notes, Participant, Assessment,
New Hires, management, Informational session

Vnswamy
07-12-2011, 08:40 AM
Oops. Didn't paste properly. Here is a link to the form (won't let me post links at 2 posts, so it is not a hyperlink):


i55.tinypic.com/xmu8ly.jpg

gmaxey
07-12-2011, 06:54 PM
I still don't have a clear idea what you are trying to achieve so I will offer this and back out.

If you have 3 tables in your document e.g., Table 1, Tabe 2, Table 3 and you want to populate the cells in Table 4 of that document with contents of specific cells of Tables 1-3 then you can use code along these lines:

Private Sub CommandButton1_Click()
Dim oTbl As Word.Table
Set oTbl = ActiveDocument.Tables(4)
oTbl.Cell(1, 1).Range.Text = Left(ActiveDocument.Tables(1).Cell(1, 2).Range.Text, Len(ActiveDocument.Tables(1).Cell(1, 2).Range.Text) - 2)
oTbl.Cell(1, 2).Range.Text = Left(ActiveDocument.Tables(2).Cell(1, 3).Range.Text, Len(ActiveDocument.Tables(2).Cell(1, 3).Range.Text) - 2)
End Sub