View Single Post
 
Old 03-08-2020, 02:43 PM
marceepoo marceepoo is offline Windows 7 64bit Office 2010 64bit
Novice
 
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