Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-08-2018, 02:08 PM
marna marna is offline need help creating a Word macro selecting all and changing font, size, and color thanks Windows 7 64bit need help creating a Word macro selecting all and changing font, size, and color thanks Office 2007
Novice
need help creating a Word macro selecting all and changing font, size, and color thanks
 
Join Date: Dec 2018
Posts: 3
marna is on a distinguished road
Wink need help creating a Word macro selecting all and changing font, size, and color thanks

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
Reply With Quote
  #2  
Old 12-08-2018, 09:34 PM
macropod's Avatar
macropod macropod is offline need help creating a Word macro selecting all and changing font, size, and color thanks Windows 7 64bit need help creating a Word macro selecting all and changing font, size, and color thanks Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #3  
Old 12-09-2018, 12:02 PM
marna marna is offline need help creating a Word macro selecting all and changing font, size, and color thanks Windows 7 64bit need help creating a Word macro selecting all and changing font, size, and color thanks Office 2007
Novice
need help creating a Word macro selecting all and changing font, size, and color thanks
 
Join Date: Dec 2018
Posts: 3
marna is on a distinguished road
Default

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
Reply With Quote
  #4  
Old 12-09-2018, 05:30 PM
macropod's Avatar
macropod macropod is offline need help creating a Word macro selecting all and changing font, size, and color thanks Windows 7 64bit need help creating a Word macro selecting all and changing font, size, and color thanks Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #5  
Old 12-18-2018, 07:20 PM
marna marna is offline need help creating a Word macro selecting all and changing font, size, and color thanks Windows 7 64bit need help creating a Word macro selecting all and changing font, size, and color thanks Office 2007
Novice
need help creating a Word macro selecting all and changing font, size, and color thanks
 
Join Date: Dec 2018
Posts: 3
marna is on a distinguished road
Default

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!!!
Reply With Quote
Reply

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
need help creating a Word macro selecting all and changing font, size, and color thanks Changing the commentary font size in WORD 2013 to a larger one MikeD Word 3 06-01-2014 03:40 AM
need help creating a Word macro selecting all and changing font, size, and color thanks 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

Other Forums: Access Forums

All times are GMT -7. The time now is 06:27 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft