Je tente d'écrire par programme un fichier Word et j'ai du mal à alterner les styles sur un objet de sélection. Voici le bit correspondant du code:Win32com se déplaçant entre Styles dans un 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.
Il semble que ma « sélection » affecte la totalité du document, mais, quand je fais ma première affectation de objSel.Style à «titre 3 lignes précédentes ne sont pas affecté. Quand je reviens à la normale tout le reste est.