Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 03-04-2020, 11:01 AM
marceepoo marceepoo is offline Help using VBA to find a hidden text string Windows 7 64bit Help using VBA to find a hidden text string Office 2010 64bit
Novice
Help using VBA to find a hidden text string
 
Join Date: Sep 2012
Posts: 22
marceepoo is on a distinguished road
Default Help using VBA to find a hidden text string

I can't figure out how to use VBA to find a hidden text string.


The following code is a macro I coded (unsuccessfully) trying to use tips in several postings I found on the web. I included a couple of comment lines I put into the macro so that I'd be able to refer to the examples I was trying (unsuccessfully) to emulate.

Code:
Sub subBkMarkFindAndBkMarkNextTblOfExhibitsPara()
    'https://benread.net/tools/macros-word-general.html    
    'https://www.office-forums.com/threads/finding-hidden-text-in-word-vba.2349850/
    Application.ScreenUpdating = False
    Dim bShow As Boolean
    bShow = ActiveWindow.View.ShowHiddenText
    ActiveWindow.View.ShowHiddenText = True
    
    With Selection.Find
      .ClearFormatting
      .Text = "[FULLNAME: PDF] "
      .MatchWildcards = False
      .Forward = False
      .Style = ActiveDocument.Styles("Heading 1")
      .Execute
      .ClearFormatting
      .Forward = True
    End With
    
    With Selection.Find
        .ClearFormatting
        .MatchWildcards = False
        .Text = "[FULLNAME: PDF] "
        .Forward = True
        .Wrap = wdFindStop
        .Format = False     
        .Font.Hidden = True
        
        If .Execute Then
            'I guess "If .Execute = True", your code continues processing from here.
            Selection.HomeKey Unit:=wdLine, Extend:=wdMove
            
            With ActiveDocument.Bookmarks
                .Add Range:=Selection.Range, Name:="LastEntryThusFarMadeInTblOfExhibits"
                .DefaultSorting = wdSortByName
                .ShowHidden = False
            End With 'With ActiveDocument.Bookmarks
            
        Else ' If .Execute Then
        
            MsgBox "Message from Macro: NMc:subBkMarkFindAndBkMarkNextTblOfExhibitsPara()" & _
                "[FULLNAME: PDF]  wasn't found."
            
        End If 'If .Execute Then
            
    End With 'With Selection.Find
    ActiveWindow.View.ShowHiddenText = bShow
    Application.ScreenUpdating = True
    
    Call subBkMarkNextEntryInTblOfExhibits
    
End Sub 'subBkMarkFindAndBkMarkNextTblOfExhibitsPara
Reply With Quote
 

Tags
hidden text, vba code, vba find and replace



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find all string within string. PRA007 Word VBA 18 02-12-2016 08:11 PM
VBA to Find and Format Text string defined using Inputbox within selection sistemalan Word VBA 7 10-03-2014 07:28 AM
Help using VBA to find a hidden text string Way to search for a string in text file, pull out everything until another string? omahadivision Excel Programming 12 11-23-2013 12:10 PM
Help using VBA to find a hidden text string Find and replace a string of text errtu Word 1 01-31-2013 02:09 PM
Help using VBA to find a hidden text string Bad view when using Find and Find & Replace - Word places found string on top line paulkaye Word 4 12-06-2011 11:05 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:53 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