Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 11-15-2022, 10:15 AM
stky stky is offline add a validate in the below macro Windows 10 add a validate in the below macro Office 2013
Advanced Beginner
add a validate in the below macro
 
Join Date: Apr 2021
Posts: 30
stky is on a distinguished road
Default add a validate in the below macro

If style not exists in the document need proceed and highlight the TAG (e.g., <H1>, <H2>, etc.)


Sub TagtoStyle()
Application.ScreenUpdating = False
Dim rngStory As Range, StrStry As String
For Each rngStory In ActiveDocument.StoryRanges
With rngStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "\<[! ]@\>"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchWildcards = True
.Execute
End With
If .Find.Found = False Then
Select Case rngStory
Case wdCommentsStory: StrStry = "Comments"
Case wdEndnotesStory: StrStry = "Endnotes"
Case wdFootnotesStory: StrStry = "Footnotes"
Case wdMainTextStory: StrStry = "Document Body"


Case Else: StrStry = ""
End Select
If StrStry <> "" Then MsgBox "No tags found in: " & StrStry, vbExclamation
End If
Do While .Find.Found = True
.Style = Split(Split(.Text, "<")(1), ">")(0)
.Text = vbNullString
.Find.Execute
Loop
End With
Next rngStory
Application.ScreenUpdating = True
End Sub
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Validate textbox fields in VBA Form before Submit ScottyBee Word VBA 5 03-20-2019 04:46 PM
How to assess / validate properties of PPT? goldscepter PowerPoint 2 08-12-2016 11:51 AM
Spell check macro within macro button field doesn't work in one document samuelle Word VBA 0 07-20-2016 02:27 AM
Validate file name in attachments Ramon Adriano Misc 0 06-23-2016 10:48 AM
Validate the height of the text when you save (VBA) jhpe Word VBA 0 08-22-2008 06:59 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:44 AM.


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