0

I am trying to get this document to change the font size but it keeps saying Pt() is not defined.

I have this:

import docx

doc = docx.Document(r"C:\Users\jconshick\Desktop\CodeTest\Spellbook.docx")
para = doc.add_paragraph('').add_run("This is a test")
para.font.size = Pt(12)
doc.save(r"C:\Users\jconshick\Desktop\CodeTest\Spellbook.docx")

I keep getting that Pt() is not defined though all the documentation shows this is how is should be. Not sure if it matters but I am using Spyder.

Jake
  • 303
  • 5
  • 19

1 Answers1

1

Try

docx.shared.Pt(12)

instead of

Pt(12)

By this answer from @PieterduToit