1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import win32com.client as win32
from time import sleep

RANGE = range(3, 8)

def word():
word = win32.gencache.EnsureDispatch('Word.Application')
doc = word.Documents.Add()
word.Visible = True
sleep(1)

rng = doc.Range(0,0)
rng.InsertAfter('Hacking Word with Pythonrnrn')
sleep(1)
for i in RANGE:
rng.InsertAfter('Line %drn' % i)
sleep(1)
rng.InsertAfter("rnPython rules!rn")

doc.Close(False)
word.Application.Quit()

if __name__ == '__main__':
word()
知识共享授权条款
本著作Chen, Zai-Chun制作,以知识共享 姓名标示-相同方式分享 4.0 国际 授权条款释出

留言

Dec 12 2010