Hi
I have a problem concerning word/excel that I am hoping someone can help me with.
I have some data in an excelsheet that I want to put in a word document. I want to put the data in a table I the word document. I have written a code I excel that creates the document and puts the data in the table I the document.
My problem is this: My code crashes when I automate word via late binding instead of early binding. And I need use late binding. It seems that I can’t access the built in constants such as wdline, wdstory etc. I have posted part of the code below:
Sub test()
Dim myWord As Object
Set myWord = CreateObject("Word.application")
With myWord
.Documents.Add
.Visible = True
.ActiveDocument.Tables.Add Range:=.Selection.Range, numrows:=1, numcolumns:=2, _
DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitContent
With .Selection
.Tables(1).UpdateAutoFormat
.Tables(1).Columns(1).SetWidth ColumnWidth:=50, rulerstyle:=wdAdjustNone
.Tables(1).Columns(2).SetWidth ColumnWidth:=250, rulerstyle:=wdAdjustNone
.Tables(1).Rows.SetHeight RowHeight:=30, HeightRule:=wdRowHeightExactly
.Tables(1).Range.Cells.VerticalAlignment = wdCellAlignVerticalCenter
End With
.Selection.typetext Text:="Hello"
.MoveRight unit:=wdCell 'this is where it crashes 'Runtime error 438. Object doesn't suport this property or method
End With
So my question is:
Is there a way to move the next cell in the table without the use of the constant: wdCell. I would like create new rows in the table as i move right?
Any help would be greatly appreciated