0
プログラムでWordファイルを書き込もうとしていますが、選択オブジェクトのスタイルを変更するのに苦労しています。ここでは、コードの該当ビットは次のとおりです。win32comがSelectoinのスタイル間を移動する
objWord = win32com.client.Dispatch("Word.Application")
objSel = objWord.Selection
writestuff = "\r\nSome Heading"
objSel.Style = objWord.ActiveDocument.Styles("Heading 3")
objSel.TypeText(writestuff)
#This works so far, we have a heading and some text, now we want to write data below the heading
objSel.Style = objWord.ActiveDocument.Styles("Normal") #Setting style back to 'Normal' for next section
writestuff = "\r\nSome data about the heading we just wrote")
objSel.TypeText(writestuff)
#At this point the heading and new text both go to the 'Normal' style.
私が私の最初のobjSel.Style割り当ては、前の行ではありません「3見出し」に作るとき、私の「選択」は、しかし、文書のすべてに影響を及ぼしていることが表示されます影響を受けた。私が正常に戻ったときには他のすべてがあります。