![]() |
|
#14
|
||||
|
||||
|
The code I posted works fine for me with your document & tables. As for the second problem, try:
Code:
Sub update_cell_data()
Dim Rng As Range, aTable As Table, TblCell As Cell, cellvalue As String, CellID As String
cellvalue = "test data" ' new value to insert into the cell below
CellID = "Cell_ID[2, 2]"
' temporarily turn on hidden text
ActiveDocument.ActiveWindow.View.ShowHiddenText = True
For Each aTable In ActiveDocument.Tables
For Each TblCell In aTable.Range.Cells
With TblCell
Set Rng = .Range
With Rng
If InStr(.Text, CellID) > 0 Then
.End = .Start + InStr(.Text, CellID) - 1
.Text = cellvalue
.Font.Hidden = False
Exit For
End If
End With
End With
Next TblCell
Next aTable
' turn off hidden text
ActiveDocument.ActiveWindow.View.ShowHiddenText = False
End Sub
Code:
Sub update_cell_data()
Dim aTable As Table, cellvalue As String
cellvalue = "test data" ' new value to insert into the cell below
For Each aTable In ActiveDocument.Tables
aTable.Cell(2, 2).Range.Text = cellvalue
Next aTable
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
| Tags |
| vba, vba word, word table |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
getting rid of hidden text in MS word
|
allenglishboy | Word | 1 | 11-06-2012 05:48 PM |
Hidden text in table
|
Angel9520 | Word Tables | 1 | 05-02-2012 01:00 AM |
Hidden style applied over already-hidden text.
|
christie | Word | 1 | 08-17-2011 09:10 AM |
| inserting a string of data into an MS Word table??? | matto | Word VBA | 0 | 07-16-2010 09:35 AM |
| Programmatically get File Path for currently opened WORD document | franferns | Word | 1 | 11-26-2009 12:36 PM |