Creating a table in Word

  • Thread starter Thread starter tonesmcbutt
  • Start date Start date
T

tonesmcbutt

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..
 
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
 
Back
Top