Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #8  
Old 03-08-2020, 02:43 PM
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 My revns to your DATE Demo get the rest of what I need, crudely

I made some revisions to your Demo posted on 03-06-2020, 08:32 PM
2020-03-06_20-32:


Quote:
Originally Posted by macropod View Post
Try:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim Rng As Range
With ActiveDocument
  Set Rng = Selection.Characters.Last
  Set Rng = Rng.GoTo(What:=wdGoToBookmark, Name:="LastEntryThusFarMadeInTblOfExhibits")
  Set Rng = Rng.GoTo(What:=wdGoToBookmark, Name:="\HeadingLevel")
  Rng.Collapse wdCollapseEnd
  Rng.End = .Range.End
  With Rng
    With .Find
      .ClearFormatting
      .Replacement.ClearFormatting
      .Text = "[!^13]@[FULLNAME: PDF] "
      .Style = "Heading 1"
      .Font.Hidden = True
      .Replacement.Text = ""
      .Forward = True
      .Format = False
      .Wrap = wdFindStop
      .MatchWildcards = True
      .Execute
    End With
    If .Find.Found = True Then
      .Collapse wdCollapseStart
      .Bookmarks.Add Name:="LastEntryThusFarMadeInTblOfExhibits", Range:=.Duplicate
    End If
  End With
End With
Application.ScreenUpdating = True
End Sub

The following is your Demo() crudely revised by me:
Quote:
Sub subMacropodDemo202003062032_MarcRevn01()
'2020-03-06_20-32 202003062032 subMacropodDemo202003062032()
Application.ScreenUpdating = False
Dim Rng As Range
With ActiveDocument
Set Rng = Selection.Characters.Last
Set Rng = Rng.GoTo(What:=wdGoToBookmark, Name:="LastEntryThusFarMadeInTblOfExhibits")
Set Rng = Rng.GoTo(What:=wdGoToBookmark, Name:="\HeadingLevel")
Rng.Collapse wdCollapseEnd
Rng.End = .Range.End
With Rng
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "[!^13]@[FULLNAME: PDF] "
.Style = "Heading 1"
.Font.Hidden = True
.Replacement.Text = ""
.Forward = True
.Format = False
.Wrap = wdFindStop
.MatchWildcards = True
.Execute
End With
If .Find.Found = True Then
.Select
.Collapse wdCollapseStart
'.Bookmarks.Add Name:="LastEntryThusFarMadeInTblOfExhibits", Range:=.Duplicate
Else
MsgBox "something went wrong here."
End If
End With
Selection.HomeKey Unit:=wdLine
Selection.Find.ClearFormatting
With Selection.Find
.Text = "^p"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchKashida = False
.MatchDiacritics = False
.MatchAlefHamza = False
.MatchControl = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.HomeKey Unit:=wdLine
' .Bookmarks.Add Name:="LastEntryThusFarMadeInTblOfExhibits", Range:=.Duplicate


With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="LastEntryThusFarMadeInTblOfExhibits"
.DefaultSorting = wdSortByName
.ShowHidden = False
End With


End With
Application.ScreenUpdating = True
End Sub 'subMacropodDemo202003062032_MarcRevn01()

I always get the error message (MsgBox "something went wrong here."), but the new bookmark does get inserted where I want it to be inserted.

Obviously, my code does not search for the next paragraph that is formatted with Heading 1 AND that contains the Text = "[!^13]@[FULLNAME: PDF] " ... so it would be great if you could show me how to do that ... since you obviously have nothing else to do with your time besides help me. (Joke)

Lastly, I want to:
Apologize for being so poor at expressing what I was trying to do; and
Thank you again, very sincerely.

Marc
Reply With Quote
 

Tags
hidden text, vba code, vba find and replace

Thread Tools
Display Modes


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 02:04 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