I just recently discovered this forum. It's wonderful to find a place with so many people willing to share their knowledge! I tried other forums before but couldn't get a reply from anyone.
I need help with the attached document!
1. It is a Document Change form with tables in Word 2007. I separated all the tables instead of having one long one in Section 1 because I thought it might be easier to work with using code. Is this a good assumption or does it even matter?
2. In Section 1a, the user will input a number "n" into the cell after "Number of affected documents:" I need to have word automatically insert "n-1" rows (including the content control) at the end of that table. As the "Doc. Number' in the "n" rows are populated, I need the tables 1b - 1e to have "n" rows added to their last row and to have the same "Doc. Numbers" populate in the first cell of each added row.
3. I've been tasked w/creating multiple documents and I'm trying to learn VBA as I go, How are cells from Word tables referenced in code? For example, if I'm referring to the cell in the 3rd row and the 2nd column in one of the tables, how would that be designated?
Thanks so much in advance!
Sandra
Last edited by garridosk; 11-18-2011 at 05:44 PM. Reason: Number questions
First question:
Sub snb() ActiveDocument.Tables(1).Rows.Last.Select Selection.InsertRowsBelow 5 End Sub
Last question:
reading:
writingc01=activedocument.Tables.cell(3,2).range
activedocument.Tables.cell(3,2).range.text="example" & chr(8)
Last edited by snb; 11-16-2011 at 02:45 PM.
Thanks for your response. I tried it 2 ways but it didn't do anything.
I clicked "Design Mode" -> "Visual Basic" -> "This document". There was a window with a previous macro "SAVE1" for saving the document to 2 different files that I had created. Under that window was another window that was empty. I pasted the code in the empty window, closed the VBA window, got out of design mode, saved the file as a macro enabled Word doc. When I typed "5" into the cell to the right of the one with "Number of affected documents" and tabbed, nothing happened. The second time I tried it, I pasted the code into the same window with the "SAVE1" macro. I removed the "End Sub" and pasted it at the end of theat code. It still didn't do anything. Am I doing something wrong?
I don't understand part of your answer to my last question. What is "c01=activedocument.Tables." ? Does that designate the 1st table in the document? What does "text="example" & chr(8)" mean/do? What is the "(8)" for?
Sandra
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks