#1
|
|||
|
|||
Table won't create
I don't know why this code does NOT create a table, even though it did in Record Macro mode, which is how I got the code!
As I stepped through this, the only thing that worked was selecting the bookmark (i.e. it navigated into the existing cell in which I had already defined a bookmark. The Tables.add command didn't do anything! How could this not work when the macro did? The table needs to be in the Due in Next 30 Days cell in the attachment. wdApp.ActiveDocument.Bookmarks("Table_5").Select wdApp.ActiveDocument.Tables.add Range:=Selection.Range, NumRows:=2, NumColumns:= _ 3, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _ wdAutoFitFixed With Selection.Tables(1) If .Style <> "Table Grid" Then .Style = "Table Grid" End If .ApplyStyleHeadingRows = True .ApplyStyleLastRow = False .ApplyStyleFirstColumn = True .ApplyStyleLastColumn = False .ApplyStyleRowBands = True .ApplyStyleColumnBands = False End With Selection.TypeText Text:="Due Date" Selection.MoveRight unit:=wdCell Selection.TypeText Text:="Staff Name" Selection.MoveRight unit:=wdCell Selection.TypeText Text:="Supervisor" Selection.MoveRight unit:=wdCell NVCITable.PNG Last edited by pbassett; 02-22-2017 at 03:15 PM. Reason: Added attachment |
#2
|
|||
|
|||
Hi,
I would modify you code this way : Code:
ActiveDocument.Bookmarks("Table_5").Select ActiveDocument.Tables.add Range:=Selection.Range, NumRows:=2, NumColumns:= _ 3, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _ wdAutoFitFixed With Selection.Tables(1) If .Style <> "Table Grid" Then .Style = "Table Grid" End If .ApplyStyleHeadingRows = True .ApplyStyleLastRow = False .ApplyStyleFirstColumn = True .ApplyStyleLastColumn = False .ApplyStyleRowBands = True .ApplyStyleColumnBands = False End With Selection.TypeText Text:="Due Date" Selection.MoveRight unit:=wdCell Selection.TypeText Text:="Staff Name" Selection.MoveRight unit:=wdCell Selection.TypeText Text:="Supervisor" Selection.MoveRight unit:=wdCell Bye! Souriane |
#3
|
|||
|
|||
Thanks! Indeed that fixed it. What a relief!
|
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to create custom table styles? | Pey1 | PowerPoint | 1 | 05-25-2016 02:15 AM |
Mail merge from excel - need to create sheets and create a table | bluenosebex | Mail Merge | 5 | 08-02-2015 05:34 PM |
Create footnotes from table... ¿AUTOMATICALLY? | jbaranao | Word | 3 | 02-08-2015 08:57 PM |
Create updating reference in table | droseman | Word | 1 | 09-05-2014 05:39 PM |
How do you create a table same size as the paper? | JayN | Word Tables | 1 | 05-26-2010 12:04 AM |