![]() |
|
|||||||
|
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Can someone help please? Not sure how to do this.
I need to create a macro for Word which will: Select All Change the font to Arial Change the size to 14 Change the color to Dark Blue (the default dark blue) Any suggestions? Thanks, Marina |
|
#2
|
||||
|
||||
|
You should not be modifying a document that way. rather, you should create a Style with the desired characteristics (or modify an existing one) and apply that. For example, the following macro does what you ask by modifying & applying Word's 'Normal' Style:
Code:
Sub FormatActiveDocument()
Application.ScreenUpdating = False
With ActiveDocument
With .Styles(wdStyleNormal).Font
.Name = "Arial"
.Size = 14
.ColorIndex = wdDarkBlue
End With
With .Range
.Style = wdStyleNormal
.ParagraphFormat.Reset
.Font.Reset
End With
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#3
|
|||
|
|||
|
Great! Thank you!
That's almost it. Two last things. Can we add a Bold to that... and is there a way to run the macro on a bunch of files in a folder? Or do i need to open all the documents and run it one by one? again thank you! Marina |
|
#4
|
||||
|
||||
|
Of course you do can both of those things. I can't imagine why anyone would want to bold an entire document, though, let alone all documents in a folder; that suggests you're specified the wrong font. It would have helped, though, if you'd taken the time to specify the scope of the task from the outset.
Code:
Sub ReformatDocuments()
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String, strDocNm As String, wdDoc As Document
strDocNm = ActiveDocument.FullName
strFolder = GetFolder
If strFolder = "" Then Exit Sub
strFile = Dir(strFolder & "\*.doc", vbNormal)
While strFile <> ""
If strFolder & "\" & strFile <> strDocNm Then
Set wdDoc = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False)
With wdDoc
With .Styles(wdStyleNormal).Font
.Name = "Arial"
.Size = 14
.Bold = True
.ColorIndex = wdDarkBlue
End With
With .Range
.Style = wdStyleNormal
.ParagraphFormat.Reset
.Font.Reset
End With
.Close SaveChanges:=True
End With
End If
strFile = Dir()
Wend
Set wdDoc = Nothing
Application.ScreenUpdating = True
End Sub
Function GetFolder() As String
Dim oFolder As Object
GetFolder = ""
Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
Set oFolder = Nothing
End Function
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#5
|
|||
|
|||
|
Sorry - I should have, you're right. What you posted helped greatly, I have what I need. I appreciate it. In case you were wondering what on earth I was trying to do..
I have a bunch of documents that are nothing but one big table. I wanted to change the default font of all, bold it all (I just like how it looks), and make the right column one color, the left column another color. It sounds crazy, but I am building something and this is just for reference for the developer. I just wanted the info to leap off the page and be easy to read (and wow it does) for when it gets reviewed. I could get more specific, but not sure you want to hear all of it. Again you did help - I got what I needed I really appreciate it Thank you!!! |
|
| Tags |
| font, font color, macro |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| When changing table style in Word 2010, font size seems to change but doesn't show in new tables | heartsoulliving | Word | 1 | 12-07-2016 05:17 PM |
| Word macro doesn't change font color | Spideriffic | Word VBA | 8 | 11-04-2015 03:47 AM |
Changing the commentary font size in WORD 2013 to a larger one
|
MikeD | Word | 3 | 06-01-2014 03:40 AM |
MAcro to List all the Font & its size in a word document
|
shaukat74 | Word VBA | 1 | 01-29-2013 09:34 PM |
| changing font size without changing leading | carolns | Word | 1 | 09-14-2009 12:30 PM |