ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Creating a table in Word (https://www.excelbanter.com/excel-programming/287629-creating-table-word.html)

tonesmcbutt[_2_]

Creating a table in Word
 
I know this is a long shot but is there anybody out there who knows ho
to create a two column table in Word from Excel and then add data int
it..

--
Message posted from http://www.ExcelForum.com


Rocky McKinley

Creating a table in Word
 
This will point you in the right direction, I recorded this macro in word
into "Normal.NewMacros" in the Vb editor. Then with the TestIt macro I call
the word macro from excel. In this case word is already open.


Sub InsertTable() 'Word Macro
ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=3,
NumColumns:= _
2, DefaultTableBehavior:=wdWord9TableBehavior,
AutoFitBehavior:=wdAutoFitFixed
With Selection.Tables(1)
If .Style < "Table Grid" Then
.Style = "Table Grid"
End If
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = True
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = True
End With

End Sub




Sub TestIt() 'Excel Macro
Set WdApp = Word.Application 'used to say "New Word.Application" when
word wasn't open
With WdApp
'.Documents.Open Filename:="C:\Macro Laden Document.doc" 'if you want to
open a document
'.Visible = True
'.WindowState = xlMaximized
'.Activate
.Application.Run MacroName:="Normal.NewMacros.InsertTable"
End With 'WdApp

Set WdApp = Nothing
End Sub


--
Regards,
Rocky McKinley


"tonesmcbutt " wrote in message
...
I know this is a long shot but is there anybody out there who knows how
to create a two column table in Word from Excel and then add data into
it...


---
Message posted from http://www.ExcelForum.com/




tonesmcbutt[_3_]

Creating a table in Word
 
Thank you for replying - I will give it a try and let you know how I got
on


---
Message posted from http://www.ExcelForum.com/



All times are GMT +1. The time now is 06:54 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com