import codecs,win32com.client # needed for converting Unicode->Ansi (in local system codepage) DecodeUnicodeString = lambda x: codecs.latin_1_encode(x)[0] word = win32com.client.Dispatch("Word.Application") doc = word.Documents.Add() doc.Content.InsertAfter("This is a header\n") doc.Content.InsertAfter("This is a body") # Note that this works, because the style applies to the whole first line. doc.Range(1,1).Style = win32com.client.constants.wdStyleHeading1 word.Visible = 1