MS Word - Set a range of cells in a table

Dawn M

Member
Anybody know how to set/select a range of cells in a table in Microsoft Word?

I'm trying to select the second and third cells of the first column of my table so I can perform a "merge" on them.
 

Dawn M

Member
Almost there....

Well, I figured out how to set the range of cells....

define variable objTable as com-handle.
define variable objSelection as com-handle.

define variable Cellstart as integer no-undo.
define variable CellEnd as integer no-undo.

objTable = objDocument:Tables:item(xtableNumber).

CellStart = objTable:columns:item(1):Cells:item(2):range:start.
CellEnd = objTable:columns:item(1):Cells:item(3):range:end.

objSelection = objDocument:Range(
objTable:columns:item(1):Cells:item(2):range:start,
objTable:columns:item(1):Cells:item(3):range:end):select.

But, for some reason, the MERGE command isn't working on them.

ANYONE?
 
If it's the same as Excel (and I think it will be),
it'll be something like:

...:Range...:Merge().

eg.

objSelection:Merge().


Remember the brackets.
 

boswell

New Member
i used...

Private Sub Command19_Click()
Dim w As New Word.Application, r As Range
w.Documents.Add
With w.ActiveDocument
Set r = .Range
.Tables.Add r, 10, 4
With .Tables(1)
.Borders.OutsideLineStyle = wdLineStyleSingle
.Borders.InsideLineStyle = wdLineStyleSingle
.Cell(1, 1).Range.InsertAfter "Account No:"
.Cell(1, 2).Range.Italic = True
.Cell(1, 2).Range.InsertAfter "Insert Invoice ID here"
.Cell(3, 1).Range.InsertAfter "In Account With:"
.Cell(3, 2).Range.InsertAfter [Form_Client_Info]![Client_Name] & vbCrLf & [Form_Client_Info]![Client_address]
.Cell(4, 1).Range.InsertAfter "Reference:"
.Cell(4, 2).Range.Bold = True
.Cell(4, 2).Range.InsertAfter [Form_Projects]![Project_ID]
.Cell(5, 1).Range.InsertAfter "Date:"

End With

End With
w.Visible = True
End Sub

still working on it though...
i don't know how to get this to work -
Cell(5, 2).Range.InsertDateTime [mm - dd - yyyy]
- the last bit ... any ideas?

boswell
 
Top