10.07.2015 Views

Automate Microsoft Office with Python - Mil-OSS

Automate Microsoft Office with Python - Mil-OSS

Automate Microsoft Office with Python - Mil-OSS

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Word Automationimport win32com.client# launch or connect to <strong>Microsoft</strong> Word.word_app = win32com.client.Dispatch("Word.Application")word_app.Visible = True92 Lorem86 Sed fa103 Curabi101 Nulla113 Sed codoc = word_app.ActiveDocument# iterate through the paragraphsfor para in doc.Paragraphs:range = para.Rangeprint '%3d %s' % (range.Words.Count, range.Text[0:6])GTRI_B-‹#›

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!