PDA

View Full Version : Sleeper: Font and Colour of Generated File



snoopies
09-06-2005, 02:24 AM
Hi all,

I'm not sure whether I'm asking the question in the right place....
If I want to write a marco to create a doc. file,
how can I write the code to decide the font size and the font colour of the text file?

Thanks a lot~:)

Jacob Hilderbrand
09-06-2005, 10:18 AM
Try something like this.



Option Explicit

Sub Macro1()
Dim AppWord As Object
Dim Doc As Object
Set AppWord = CreateObject("Word.Application")
Set Doc = AppWord.Documents.Add
AppWord.Selection.Font.Name = "Arial"
AppWord.Selection.Font.Size = 12
AppWord.Selection.Font.ColorIndex = 3
AppWord.Selection.TypeText Text:="This is a test."
AppWord.Visible = True
Set Doc = Nothing
Set AppWord = Nothing
End Sub