Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-11-2024, 08:44 AM
Shelley Lou Shelley Lou is offline VBA Plain Definitions formatted Bold Windows 10 VBA Plain Definitions formatted Bold Office 2016
Expert
VBA Plain Definitions formatted Bold
 
Join Date: Dec 2020
Posts: 259
Shelley Lou is on a distinguished road
Default VBA Plain Definitions formatted bold

Hi Vivka, I have attached a test document. I want to be able to select just one plain text plain quote or select multiple if they are close together that need to be formatted - it must be on selection though. The plain text plain quotes are displayed on their own or maybe within brackets.



Test Plain Text with Plain Quotes Code.docx

Last edited by Shelley Lou; 10-11-2024 at 08:53 AM. Reason: Adding test document
Reply With Quote
  #2  
Old 10-11-2024, 09:52 AM
vivka vivka is offline VBA Plain Definitions formatted Bold Windows 7 64bit VBA Plain Definitions formatted Bold Office 2016
Expert
 
Join Date: Jul 2023
Posts: 305
vivka is on a distinguished road
Default

Shelley Lou, please, try this:
Code:
Sub PlainDefinition_FormatBold()
'Select one or more definitions with plain text and plain quotes and format bold
Dim rng As range
Application.ScreenUpdating = False
If selection.Type = wdSelectionIP Then
 'MsgBox Prompt:="You have not selected any text!"
 MsgBox "You have not selected any text!", vbExclamation, "Invalid selection"
 Exit Sub
End If
Set rng = selection.range
With rng.Find
   .ClearFormatting
   .Replacement.ClearFormatting
   .Forward = False
   .Wrap = wdFindStop
   .Format = True
   .MatchWildcards = True
   .text = "[""""]*[""""]" 'Find any text within quotes
   .Replacement.Font.Bold = True 'Replacement text is bold
   .Execute Replace:=wdReplaceAll
   .text = "\([""""]*[""""]\)" 'Find any text within quotes within brackets
   .Replacement.Font.Bold = True
   .Execute Replace:=wdReplaceAll
   End With
   Application.ScreenUpdating = True
  Set rng = Nothing
 End Sub
Note: instead of """" you may use "" in all occurrences. Tip: If you want to embolden a selected range, you don't need a macro - just press Alt+B.
And the final remark: in your sample (...by the Landlord to the Tenant in writing") the " is an orphan (= it is not paired), so it could cause false emboldening.
Reply With Quote
  #3  
Old 10-14-2024, 03:51 AM
Shelley Lou Shelley Lou is offline VBA Plain Definitions formatted Bold Windows 10 VBA Plain Definitions formatted Bold Office 2016
Expert
VBA Plain Definitions formatted Bold
 
Join Date: Dec 2020
Posts: 259
Shelley Lou is on a distinguished road
Default VBA Plain Definitions formatted bold

Thanks Vivka, much appreciated
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Plain Definitions formatted Bold VBA format plain quotes to bold quotes Shelley Lou Word VBA 3 02-11-2024 05:56 AM
Bold Header if it is not Bold (Check to see if it is Bold) armendarizj Word 2 01-06-2022 05:45 PM
VBA Plain Definitions formatted Bold Help with Definitions Macro Shelley Lou Word VBA 3 12-11-2020 01:39 AM
VBA Plain Definitions formatted Bold Replacing formatted bullet points as a plain text character? onlywonderboy Word VBA 6 02-21-2017 03:20 PM
VBA Plain Definitions formatted Bold How to update fields in all header definitions ChrisBrewster Word VBA 2 02-10-2014 10:33 AM

Other Forums: Access Forums

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