testMSOffice.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:CodeReader 作者: jasonrbr 项目源码 文件源码
def TestWord8(word):
    word.Visible = 1
    doc = word.Documents.Add()
    wrange = doc.Range()
    for i in range(10):
        wrange.InsertAfter("Hello from Python %d\n" % i)
    paras = doc.Paragraphs
    for i in range(len(paras)):
        p = paras[i]()
        p.Font.ColorIndex = i+1
        p.Font.Size = 12 + (4 * i)
    # XXX - note that
    # for para in paras:
    #       para().Font...
    # doesnt seem to work - no error, just doesnt work
    # Should check if it works for VB!
    doc.Close(SaveChanges = 0)
    word.Quit()
    win32api.Sleep(1000) # Wait for word to close, else we
    # may get OA error.
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号