First of all thanks for taking a look. I recognize that merged cells are trouble, but I'm not sure if there's another way.
1. I've attached an example table to explain why the cells are being merged.
1. WHY are you merging cells? This is asking for trouble...because
2. VBA does not work with ranges in columns, AND it does not work with merged cells.
3. I hope you have just written in partial code, as you have undelcared varianles, and unSET objects. Just one...
2. I'm not really sure what you mean here; VBA can merge two cells in the same row but not in the same column?
3. The code you saw was my latest attempt at just putting together some logic for the macro, and you're right it's not great.
I'm brand new to working with Word VBA, so I'm just not sure the best way to approach this. This is what I've seen in the FAQ from Word:
And here's something I was looking at for inspiration:
If ActiveDocument.Tables.Count >= 1 Then
.Cell(Row:=1, Column:=1).Merge _
.Borders.Enable = False
Any help or guidance you can provide would be greatly appreciated.
Dim oCell As Word.Cell
' \\ Check if selection is in a table
If .Information(wdWithInTable) Then
' \\ Loop Through all cells in table
For Each oCell In .Tables(1).Range.Cells
' \\ Check if the cell only has a
' \\ end of cell marker (Chr(13) and Chr(7))
If oCell.Range.Text = Chr(13) & Chr(7) Then
' \\ Cell is empty give it texture
oCell.Shading.Texture = wdTextureSolid