Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #12  
Old 12-20-2013, 11:11 AM
epid011 epid011 is offline programmatically inserting hidden text into a Word 2010 table Windows 7 64bit programmatically inserting hidden text into a Word 2010 table Office 2010 32bit
Novice
programmatically inserting hidden text into a Word 2010 table
 
Join Date: Dec 2013
Posts: 12
epid011 is on a distinguished road
Default programmatically inserting hidden text into a Word 2010 table

One more question on this topic. Now that I have a hidden cell ID in each cell, I want to have some new data that needs to replace the existing data in a particular cell. I wrote the following code to loop through the cells and replace the data in a given cell. However, it replaces both the visible and hidden text; I want the hidden text to remain as is.

Code:
 Sub update_cell_data()

     NewCellValue = "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
    
    Dim Rng As Range, aTable As Table, r As Long, c As Long, CellText As String, FoundText as Boolean
     For Each aTable In ActiveDocument.Tables
        With aTable
            For r = 1 To .Rows.Count
                For c = 1 To .Columns.Count
                    CellText = .Cell(r, c).Range.Text
                    FoundText = InStr(CellText, CellID)
                    If FoundText Then
                        MsgBox "here"
                        .Cell(r, c).Range.Text = NewCellValue
                    End If
                Next
            Next
        End With
    Next aTable
    
    ' turn off hidden text
    ActiveDocument.ActiveWindow.View.ShowHiddenText = False
End Sub
Reply With Quote
 

Tags
vba, vba word, word table



Similar Threads
Thread Thread Starter Forum Replies Last Post
programmatically inserting hidden text into a Word 2010 table getting rid of hidden text in MS word allenglishboy Word 1 11-06-2012 05:48 PM
programmatically inserting hidden text into a Word 2010 table Hidden text in table Angel9520 Word Tables 1 05-02-2012 01:00 AM
programmatically inserting hidden text into a Word 2010 table 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

Other Forums: Access Forums

All times are GMT -7. The time now is 06:21 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft