onenote使用python开发_Python Pywin& OneNote COM:OneNote.Application.15'不能自动化makepy进程'...

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值