Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-22-2017, 03:08 PM
pbassett pbassett is offline Table won't create Windows 7 64bit Table won't create Office 2010 64bit
Novice
Table won't create
 
Join Date: Feb 2017
Posts: 6
pbassett is on a distinguished road
Default 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
Reply With Quote
  #2  
Old 02-23-2017, 10:20 AM
Souriane Souriane is offline Table won't create Windows 7 64bit Table won't create Office 2013
Advanced Beginner
 
Join Date: Feb 2017
Location: Quebec, Canada
Posts: 82
Souriane is on a distinguished road
Default

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
I took the wdApp off in front of "ActiveDocument".

Bye!

Souriane
Reply With Quote
  #3  
Old 02-23-2017, 11:22 AM
pbassett pbassett is offline Table won't create Windows 7 64bit Table won't create Office 2010 64bit
Novice
Table won't create
 
Join Date: Feb 2017
Posts: 6
pbassett is on a distinguished road
Default

Thanks! Indeed that fixed it. What a relief!
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Table won't create How to create custom table styles? Pey1 PowerPoint 1 05-25-2016 02:15 AM
Table won't create Mail merge from excel - need to create sheets and create a table bluenosebex Mail Merge 5 08-02-2015 05:34 PM
Table won't create Create footnotes from table... ¿AUTOMATICALLY? jbaranao Word 3 02-08-2015 08:57 PM
Table won't create 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

Other Forums: Access Forums

All times are GMT -7. The time now is 01:54 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft