Macro to increase Font of selected text
-
- 3StarLounger
- Posts: 278
- Joined: 04 Aug 2010, 19:50
Macro to increase Font of selected text
Am trying to create a macro that when I select text, it increases it to 14 (Times New Roman). Trying but failing
I know to use the keyboard to select the text. I then go to Font window to increase size to 14, then I exit the macro and --nothing.
Thank you
I know to use the keyboard to select the text. I then go to Font window to increase size to 14, then I exit the macro and --nothing.
Thank you
-
- Administrator
- Posts: 78536
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Macro to increase Font of selected text
How about
Code: Select all
Sub FontSize14()
On Error GoTo ErrHandler
Selection.Font.Size = 14
Exit Sub
ErrHandler:
MsgBox "Cannot set font size of this selection!", vbExclamation
End Sub
Best wishes,
Hans
Hans
-
- 3StarLounger
- Posts: 278
- Joined: 04 Aug 2010, 19:50
-
- 5StarLounger
- Posts: 621
- Joined: 10 Jan 2016, 15:56
- Location: Madison, Wisconsin
Re: Macro to increase Font of selected text
A different method would be to create a character style that has TNR 14 pt and apply that rather than direct formatting through a macro.
You can attach a keyboard shortcut to that style. Doing this makes for less complex document files.
https://answers.microsoft.com/en-us/mso ... 5883735330
You can attach a keyboard shortcut to that style. Doing this makes for less complex document files.
https://answers.microsoft.com/en-us/mso ... 5883735330
Attorney Charles Kenyon
Templates in Microsoft Word
Modifying the QAT
The Importance of Styles in Microsoft Word
Templates in Microsoft Word
Modifying the QAT
The Importance of Styles in Microsoft Word
-
- PlutoniumLounger
- Posts: 15641
- Joined: 24 Jan 2010, 23:23
- Location: brings.slot.perky
Re: Macro to increase Font of selected text
I agree, except I would have started "A better method .." where by better I mean less time spent further down the road.
Cheers, Chris
He who plants a seed, plants life.
-
- 3StarLounger
- Posts: 278
- Joined: 04 Aug 2010, 19:50
Re: Macro to increase Font of selected text
Thank you Chris, Charles, but Hans' methods works fine for me, and it is what I am accustomed to.
-
- 5StarLounger
- Posts: 621
- Joined: 10 Jan 2016, 15:56
- Location: Madison, Wisconsin
Re: Macro to increase Font of selected text
Uncle,
If you are regularly using Word you NEED to learn to use styles. Every minute you spend using Word without using styles is a half hour you'll spend down the road trying to fix something.
https://www.addbalance.com/usersguide/s ... m#Overview
If you are regularly using Word you NEED to learn to use styles. Every minute you spend using Word without using styles is a half hour you'll spend down the road trying to fix something.
https://www.addbalance.com/usersguide/s ... m#Overview
Attorney Charles Kenyon
Templates in Microsoft Word
Modifying the QAT
The Importance of Styles in Microsoft Word
Templates in Microsoft Word
Modifying the QAT
The Importance of Styles in Microsoft Word
-
- PlutoniumLounger
- Posts: 15641
- Joined: 24 Jan 2010, 23:23
- Location: brings.slot.perky
Re: Macro to increase Font of selected text
Charles, I disagree.Charles Kenyon wrote: ↑14 Jul 2022, 18:45Every minute you spend using Word without using styles is a half hour you'll spend down the road trying to fix something.
I spent many years converting old documents of my clients to MSWord and cleaning them up on the way.
That is the basis of my DoCle[an] application
"Every minute you spend using Word without using styles is a several hours you'll spend down the road trying to fix something".
Uncle. I promise you: Start using Styles in MSWord, MSExcel and so on. You WILL be glad that you did.
Let me know here if you would like me to supply some simple but good examples.
Cheers, Chris
He who plants a seed, plants life.
-
- 5StarLounger
- Posts: 621
- Joined: 10 Jan 2016, 15:56
- Location: Madison, Wisconsin
Re: Macro to increase Font of selected text
I agree but was afraid of being dismissed as too pro-styles.
Attorney Charles Kenyon
Templates in Microsoft Word
Modifying the QAT
The Importance of Styles in Microsoft Word
Templates in Microsoft Word
Modifying the QAT
The Importance of Styles in Microsoft Word
-
- PlutoniumLounger
- Posts: 15641
- Joined: 24 Jan 2010, 23:23
- Location: brings.slot.perky
Re: Macro to increase Font of selected text
Charles, you are a bright young lad ; Tell me, how on earth can one be TOO pro-styles?Charles Kenyon wrote: ↑21 Jul 2022, 16:58I agree but was afraid of being dismissed as too pro-styles.
I used to demonstrate in class how styles, properly set up, can basically create a document by judicious use of "Style for following paragraph".
Then I wrote an application that worked out an appropriate level (1 through 9) for every paragraph in a document, worked out where the transition of levels suggested a Heading-n paragraph, worked out appropriate text for that paragraph, and hence generated a Heading-n paragraph of text, so that a TOC could be generated automatically from an un-styled document.
Mind you, some folks think that I'm a bit obsessive when it comes to The Power Of Styles
Cheers, Chris
He who plants a seed, plants life.
-
- 3StarLounger
- Posts: 278
- Joined: 04 Aug 2010, 19:50
Re: Macro to increase Font of selected text
Chris -Thank you for your kind offer but I am happy w/o styles. I do not use Word for reports or other business reasons so I don't have long documents and have the need for different styles.
-
- 5StarLounger
- Posts: 621
- Joined: 10 Jan 2016, 15:56
- Location: Madison, Wisconsin
Re: Macro to increase Font of selected text
@uncle,
You get to make your choices; you are an adult.
Please take a moment to read what I wrote here: https://www.addbalance.com/usersguide/s ... m#Overview
In part, I wrote long ago:
The link provides more information and quotes.
You get to make your choices; you are an adult.
Please take a moment to read what I wrote here: https://www.addbalance.com/usersguide/s ... m#Overview
In part, I wrote long ago:
Trying to use Word without understanding and using styles is like pushing on a string. I resisted learning and using styles for years and now regret every day of those years because although that string was still very hard to push, it kept getting longer and longer, and had some very important projects tied to it! Once you understand styles and the Word concept of organizing things into Chinese boxes everything falls into place and instead of pushing a string, you can push a button that turns on the very powerful text processing machine known as Microsoft Word and it will start doing your work for you instead of running around behind you trying to undo what you thought you just did.
The link provides more information and quotes.
Attorney Charles Kenyon
Templates in Microsoft Word
Modifying the QAT
The Importance of Styles in Microsoft Word
Templates in Microsoft Word
Modifying the QAT
The Importance of Styles in Microsoft Word
-
- UraniumLounger
- Posts: 9295
- Joined: 13 Feb 2010, 01:27
- Location: Deep in the Heart of Texas
Re: Macro to increase Font of selected text
Sorry, Charles! I missed your link. I can see spending a good deal of time there.
Bob's yer Uncle
Dell Intel Core i5 Laptop, 3570K,1.60 GHz, 8 GB RAM, Windows 11 64-bit, LibreOffice,and other bits and bobs
(1/2)(1+√5) |
-
- 5StarLounger
- Posts: 621
- Joined: 10 Jan 2016, 15:56
- Location: Madison, Wisconsin
Re: Macro to increase Font of selected text
Here is another, shorter, page.
http://www.shaunakelly.com/word/styles/stylesms.html
http://www.shaunakelly.com/word/styles/stylesms.html
Attorney Charles Kenyon
Templates in Microsoft Word
Modifying the QAT
The Importance of Styles in Microsoft Word
Templates in Microsoft Word
Modifying the QAT
The Importance of Styles in Microsoft Word