Python Pywin& OneNote COM:OneNote.Application.15'不能自动化makepy进程' [英] Python Pywin & OneNote COM: OneNote.Application.15 'cannot automate the makepy process'
问题描述
我正在使用Win32上的Python与OneNote的COM互操作进行交互。
这是最基本的代码来拉出笔记本层次结构:
import win32com.client
onObj = win32com.client.gencache.EnsureDispatch('OneNote.Application.12')
result = onObj。 GetHierarchy(,win32com.client.constants.hsNotebooks)
print(result)
注意 OneNote.Application.12
,这是我所期望的。
运行Makepy我其实选择v15类型库:
如果我将代码更改为 OneNote.Application.15
OneNote.Application
然后我得到一个错误:
TypeError:对象不能自动化makepy进程 - 请为此对象手动运行makepy
为什么要这样做?我正在运行:
- Python 3.3.1(64位)
- Pywin build 218 )
- Win 8 x64
- Office 2013 x64
HKEY_CLASSES_ROOT\TypeLib \ {0EA692EE-BB50-4E3C-AEF0-356D91732725}
这个奇怪的bevahior可能是由于存在无效的子键而引起的。这个类键只能包含一个子键1.1,没有别的。
此类的正确注册表记录应如下所示:
| - {0EA692EE-BB50-4E3C-AEF0-356D91732725}
| | - 1.1
| | -0
| | | - win32
| | - FLAGDS
| | - HELPDIR
键win32必须指向OneNote可执行文件。 C:\PROGRA〜1\MICROS〜1\Office15\ONENOTE.EXE\3
I'm interacting with OneNote's COM interop using Python on Win32.
Here's the most basic code to pull out notebook hierarchy:
import win32com.client
onObj = win32com.client.gencache.EnsureDispatch('OneNote.Application.12')
result = onObj.GetHierarchy("",win32com.client.constants.hsNotebooks)
print(result)
Note the OneNote.Application.12
, this works as I'd expect.
The thing is that when I run Makepy I'm actually selecting the v15 type library:
If I change the code to be either OneNote.Application.15
or just OneNote.Application
then I get an error:
TypeError: This COM object can not automate the makepy process - please run makepy manually for this object
Why is this please? I'm running:
- Python 3.3.1 (64bit)
- Pywin build 218 (AMD64)
- Win 8 x64
- Office 2013 x64
Check your registry record, in particular key {0EA692EE-BB50-4E3C-AEF0-356D91732725} in TypeLib section:
HKEY_CLASSES_ROOT\TypeLib\{0EA692EE-BB50-4E3C-AEF0-356D91732725}
This strange bevahior is probably caused by existence of invalid subkeys. This class key have to contain only a single subkey "1.1" and nothing else.
The correct registry record for this class should look as follows:
|- {0EA692EE-BB50-4E3C-AEF0-356D91732725}
| |- 1.1
| |-0
| | |- win32
| |- FLAGDS
| |- HELPDIR
The key "win32" have to point to OneNote executable, e.g. C:\PROGRA~1\MICROS~1\Office15\ONENOTE.EXE\3
这篇关于Python Pywin& OneNote COM:OneNote.Application.15'不能自动化makepy进程'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!