Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.word.tables
|
|||
|
|||
![]()
I have a Word template that contains one table of 1-4 rows and 4 columns (the
table is to record the document's revision history). I have a macro that inserts a blank row and the current date in the first column of that row, but if I run the macro again, the date goes outside the table. The macro is executed as an AutoNew command so that it runs as soon as a document is created from the template. It works fine for that one-time run at document creation. However, once the new document has been created, there will be a need to run a macro to insert a blank row in the same table. If this macro is run twice, it puts the date outside the table because the cursor is still in the table. Also, there may be another one or more tables in the document when it is edited, and I would prefer to have the macro locate only that table by some unique identifier, such as a bookmark. I've seen code that locates tables according to specific text as well as the first table in a document (as shown below), but I have not been able to determine if there is a way to find a table uniquely. The row insertion code is: ActiveDocument.Tables(1).Rows.Add rownum = ActiveDocument.Tables(1).Rows.Count Date insertion code is: Selection.InsertDateTime DateTimeFormat:="MMMM d, yyyy", InsertAsField:= _ False, DateLanguage:=wdEnglishUS, CalendarType:=wdCalendarWestern, _ InsertAsFullWidth:=False So, can someone help me with a macro that will: 1. Find a table by a unique identifier 2. Insert a blank row at the end and the current date in its first column 3. Be able to do 1 and 2 more than once in a document created from a template. Thank you. |