`word.InchesToPoints` выдает «com_error» при взаимодействии MS Word с win32com.client из pywin32Python

Программы на Python
Anonymous
`word.InchesToPoints` выдает «com_error» при взаимодействии MS Word с win32com.client из pywin32

Сообщение Anonymous »

Вот мой код:

Код: Выделить всё

import win32com.client as win32
word = win32.gencache.EnsureDispatch('Word.Application')
doc = word.Documents.Add()
indent = word.InchesToPoints(0.5)
doc.Styles("Heading 2").ParagraphFormat.LeftIndent = indent
Исключение:

Код: Выделить всё

Traceback (most recent call last):
File "test.py", line 4, in 
indent  = word.InchesToPoints(0.5)
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\meow\AppData\Local\Temp\gen_py\3.11\00020905-0000-0000-C000-000000000046x0x8x7\_Application.py", line 179, in InchesToPoints
return self._oleobj_.InvokeTypes(370, LCID, 1, (4, 0), ((4, 1),),Inches
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pywintypes.com_error: (-2147467259, 'Unspecified error', None, None)
Мой вопрос: почему word.InchesToPoints не работает. Нужно ли мне обернуть 0,5 в какой-то объект, чтобы перейти в InchesToPoints?

Подробнее здесь: https://stackoverflow.com/questions/790 ... h-win32com

Вернуться в «Python»