Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adjusting Font Size in a Text File

Status
Not open for further replies.

RWWAMS

Technical User
Jan 3, 2003
104
US
Hi everyone,

I'm writing to a text file from Microsoft Excel. Users then open the text file with Microsoft Word, however the default font size is a little too large. Is there any way to adjust the font size when the file is written? Currently, the user must open the file, then change the font size for the entire text. I'd like to automate this needless step. Any ideas or examples would be very much appreciated.

Thanks in advance!
 
Hi,
Text files have no font size. When a text file is opened in Word, Word assigns some default. Where that is set, I don't know.

But here's a way to do it with VBA code stored in each user's Normal.dot
Code:
Sub SetDefaultFont()
    Dim aRange As Range
    If Right(ActiveDocument.Name, 3) = "doc" Then Exit Sub
    
    Set aRange = ActiveDocument.Range( _
    Start:=ActiveDocument.Paragraphs(1).Range.Start, _
    End:=ActiveDocument.Paragraphs(ActiveDocument.Paragraphs.Count).Range.End)

    With aRange.Font
        .Name = "Times New Roman"
        .Size = 10
        .Bold = False
        .Italic = False
        .Underline = wdUnderlineNone
        .UnderlineColor = wdColorAutomatic
        .StrikeThrough = False
        .DoubleStrikeThrough = False
        .Outline = False
        .Emboss = False
        .Shadow = False
        .Hidden = False
        .SmallCaps = False
        .AllCaps = False
        .Color = wdColorAutomatic
        .Engrave = False
        .Superscript = False
        .Subscript = False
        .Spacing = 0
        .Scaling = 100
        .Position = 0
        .Kerning = 0
        .Animation = wdAnimationNone
    End With
End Sub
It takes any file that you are opening in Word that is NOT saved as .doc and reformats the Font.

Hope this helps :)

Skip,
Skip@TheOfficeExperts.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top