Reading Table Contet In Header And Footer In MS-Word File Using Python

前端 未结 2 442
情歌与酒
情歌与酒 2021-01-22 03:49

This is my extended question for the question:

How to read contents of an Table in MS-Word file Using Python?

The solution provided by @YusuMishi is great, but

2条回答
  •  孤街浪徒
    2021-01-22 03:57

    Unfortunately I'm not phyton programmer but have some knowledge of MS-Word VBA and objects hierarchy. This would be to much text to put in comment (where I'd rather put this tip).

    If you search your table you have to analyse different Document.StoryRanges to find your table. There are Footers and Headers but they are additionally divided into different types. So, to find you Table 0 you could use something of this structure:

    This is VBA code!! I hope you could adjust to your needs. And do it separately for you footers.

    doc.StoryRanges(wdEvenPagesHeaderStory).Tables.Count
    doc.StoryRanges(wdFirstPageHeaderStory).Tables.Count
    doc.StoryRanges(wdPrimaryHeaderStory).Tables.Count
    

提交回复
热议问题