Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-13-2022, 10:56 AM
Keithronaut Keithronaut is offline VBA Code to turn all text in a document black based on font, size, or other attributes Windows 11 VBA Code to turn all text in a document black based on font, size, or other attributes Office 2021
Novice
VBA Code to turn all text in a document black based on font, size, or other attributes
 
Join Date: Dec 2022
Posts: 5
Keithronaut is on a distinguished road
Question VBA Code to turn all text in a document black based on font, size, or other attributes

Hello, I searched and browsed this forum for a similar question and wasn't able to piece any code together for exactly what I need, so any help would be greatly appreciated. I have a document with a few different fonts/sizes and I only want to turn the Calibri 11.5 pt. black while leaving the rest of the font as-is. Thank you so much in advance!
Reply With Quote
  #2  
Old 12-13-2022, 01:39 PM
Italophile Italophile is offline VBA Code to turn all text in a document black based on font, size, or other attributes Windows 11 VBA Code to turn all text in a document black based on font, size, or other attributes Office 2021
Expert
 
Join Date: Mar 2022
Posts: 539
Italophile is just really niceItalophile is just really niceItalophile is just really niceItalophile is just really nice
Default

You do realize that you can do this using Find, don’t you?
Reply With Quote
  #3  
Old 12-13-2022, 01:56 PM
Keithronaut Keithronaut is offline VBA Code to turn all text in a document black based on font, size, or other attributes Windows 11 VBA Code to turn all text in a document black based on font, size, or other attributes Office 2021
Novice
VBA Code to turn all text in a document black based on font, size, or other attributes
 
Join Date: Dec 2022
Posts: 5
Keithronaut is on a distinguished road
Default

Quote:
Originally Posted by Italophile View Post
You do realize that you can do this using Find, don’t you?
Like I stated in the beginning of my inquiry, I searched for quite awhile for a similar thread to mine and wasn't able to piece anything together for my exact situation. I guess I should have specifically stated that I used the "Find" field to do that. What's the point of having a forum where less-skilled people ask experts questions if they're just going to get condescending replies?
Reply With Quote
  #4  
Old 12-13-2022, 04:09 PM
Italophile Italophile is offline VBA Code to turn all text in a document black based on font, size, or other attributes Windows 11 VBA Code to turn all text in a document black based on font, size, or other attributes Office 2021
Expert
 
Join Date: Mar 2022
Posts: 539
Italophile is just really niceItalophile is just really niceItalophile is just really niceItalophile is just really nice
Default

Sorry, I didn't realise that asking a question was condescending.

Using Advanced Find you can do a Find and Replace that will apply formatting to all text that has a specific format, without changing either the text or any other formatting. See screenshot below.
Attached Images
File Type: png Screenshot_20221213_111242.png (23.9 KB, 20 views)

Last edited by Italophile; 12-14-2022 at 02:07 AM.
Reply With Quote
  #5  
Old 12-13-2022, 06:32 PM
Guessed's Avatar
Guessed Guessed is offline VBA Code to turn all text in a document black based on font, size, or other attributes Windows 10 VBA Code to turn all text in a document black based on font, size, or other attributes Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,160
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Also note that (if your theme fonts are set to Calibri) this find/replace could miss Calibri text that is formatted with a font of "+Body" or ""+Headings"

You can record the actions of this dialog to make a macro version of it.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #6  
Old 12-15-2022, 04:01 AM
ChrisGreaves ChrisGreaves is offline VBA Code to turn all text in a document black based on font, size, or other attributes Windows 10 VBA Code to turn all text in a document black based on font, size, or other attributes Office 97-2003
Novice
 
Join Date: Nov 2022
Location: Bonavista, Newfoundland
Posts: 22
ChrisGreaves is on a distinguished road
Default

Quote:
Originally Posted by Keithronaut View Post
... I only want to turn the Calibri 11.5 pt. black while leaving the rest of the font as-is. Thank you so much in advance!
Hello Keith. This was my business back in the 90s for multiple documents from multiple sources.
All "document cleansing" is based on locating specific items and substituting items with (usually) different characteristics, all the way from text, fonts, sequence numbering and WP5.1 document tables (built with those weird graphic characters) with MSWord tables.


I found it expedient to write a single find-and-replace macro and then feed it the input and output characteristics from a table of rules which drove the whole process. I use the same procedure to this day.


If you anticipate repeated use of find-and-replace code to change numerous items and/or characteristics, please let me know and I will make my code available to you.
Cheers, Chris
Reply With Quote
  #7  
Old 12-16-2022, 02:37 PM
Keithronaut Keithronaut is offline VBA Code to turn all text in a document black based on font, size, or other attributes Windows 11 VBA Code to turn all text in a document black based on font, size, or other attributes Office 2021
Novice
VBA Code to turn all text in a document black based on font, size, or other attributes
 
Join Date: Dec 2022
Posts: 5
Keithronaut is on a distinguished road
Default

Quote:
Originally Posted by Italophile View Post
Sorry, I didn't realise that asking a question was condescending.

Using Advanced Find you can do a Find and Replace that will apply formatting to all text that has a specific format, without changing either the text or any other formatting. See screenshot below.
Thank you, and sorry for reading your initial response in a condescending tone if it wasn't meant to be. I appreciate your response.
Reply With Quote
  #8  
Old 12-16-2022, 02:40 PM
Keithronaut Keithronaut is offline VBA Code to turn all text in a document black based on font, size, or other attributes Windows 11 VBA Code to turn all text in a document black based on font, size, or other attributes Office 2021
Novice
VBA Code to turn all text in a document black based on font, size, or other attributes
 
Join Date: Dec 2022
Posts: 5
Keithronaut is on a distinguished road
Default

Quote:
Originally Posted by ChrisGreaves View Post
Hello Keith. This was my business back in the 90s for multiple documents from multiple sources.
All "document cleansing" is based on locating specific items and substituting items with (usually) different characteristics, all the way from text, fonts, sequence numbering and WP5.1 document tables (built with those weird graphic characters) with MSWord tables.


I found it expedient to write a single find-and-replace macro and then feed it the input and output characteristics from a table of rules which drove the whole process. I use the same procedure to this day.


If you anticipate repeated use of find-and-replace code to change numerous items and/or characteristics, please let me know and I will make my code available to you.
Cheers, Chris
Hi Chris, thank you for the response. If it's not too much trouble I would love just a simple code to find all of the 11.5 pt. Calibri font within an entire Word Document and automatically turn it black. I'm new to a lot of the VBA coding and all of my attempts so far are returning errors. I certainly appreciate your response!
Reply With Quote
  #9  
Old 12-18-2022, 07:24 AM
ChrisGreaves ChrisGreaves is offline VBA Code to turn all text in a document black based on font, size, or other attributes Windows 10 VBA Code to turn all text in a document black based on font, size, or other attributes Office 97-2003
Novice
 
Join Date: Nov 2022
Location: Bonavista, Newfoundland
Posts: 22
ChrisGreaves is on a distinguished road
Default

Quote:
Originally Posted by Keithronaut View Post
... I would love just a simple code to find all of the 11.5 pt. Calibri font within an entire Word Document and automatically turn it black.
Hi Keith. Well, there's bad news and there's even worse news.
First the bad news: Recording a simple macro to effect your specific needs doesn't work; at least, I can't make it work.
Now for the even worse news: I have confirmed that there is a bug in Recording and a bug in Executing macros to effect a change in colour.

Hi everyone else!

I use Word2003/VBA, and decided to record a simple Edit/Replace macro to effect a change to ADD a colour to any Courier New font. I chose to change to Orange, any text formatted in Courier New, because my text document was already black font; that doesn't change the form of the macro code.

In my text document I had text formatted locally in Courier New, and text formatted with a character style that used Courier New. So both local and style formatting.

My recorded macro did NOT record the colour change, although the change took effect while I was recording the macro.
I then edited my macro to use ".Replacement.Font.Color = wdColorOrange" and ".Replacement.Style = "csOrange"" with no success.

A colleague has since confirmed this behaviour with Word2021.

That thread can be read here.
Cheers, Chris
Reply With Quote
  #10  
Old 12-20-2022, 09:23 AM
Keithronaut Keithronaut is offline VBA Code to turn all text in a document black based on font, size, or other attributes Windows 11 VBA Code to turn all text in a document black based on font, size, or other attributes Office 2021
Novice
VBA Code to turn all text in a document black based on font, size, or other attributes
 
Join Date: Dec 2022
Posts: 5
Keithronaut is on a distinguished road
Default

Hey Chris, thank you very much for trying. I'll see what kind of other strategies/properties I might be able to use to specify the text that I want changed and will let you know if I figure out a workaround. Again, thanks for trying! Hopefully we'll get to the bottom of it!
Reply With Quote
Reply

Tags
font color



Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Code to turn all text in a document black based on font, size, or other attributes Using custom style instead of inserting font attributes manually in VBA code laith93 Word VBA 2 11-07-2021 12:52 AM
Duplicating Ranges and changing Font Attributes CharlieM Word VBA 3 08-10-2021 04:44 AM
VBA Code to turn all text in a document black based on font, size, or other attributes Merging two Word documents: 2nd document not maintaining original font type and font size Swarup Word 31 08-28-2018 06:55 PM
Locking Header/Footer on Document but still be able to edit body text (size, font, bold, etc) Porkie96 Word 1 06-21-2018 01:56 PM
VBA Code to turn all text in a document black based on font, size, or other attributes Character based Search and Replace font size anacond11 Word 2 08-08-2013 08:10 AM

Other Forums: Access Forums

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