脚本桥和生成Microsoft Word头文件 [英] Scripting bridge and generate Microsoft Word header file

查看:145
本文介绍了脚本桥和生成Microsoft Word头文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图获得一个Cocoa应用程序连接到Microsoft Word,从我的搜索,似乎唯一的方法是使用脚本桥和生成一个字头文件。但是,使用Apples示例项目 SBSendEmail

I’m trying to get a Cocoa application to connect to Microsoft Word, and from my search it seems that the only way, is to use Scripting Bridge and generate a word header file. However, using the approach explained in Apples example project SBSendEmail:

sdef "$INPUT_FILE_PATH" | sdp -fh -o "$DERIVED_FILES_DIR" --basename "$INPUT_FILE_BASE" --bundleid `defaults read "$INPUT_FILE_PATH/Contents/Info" CFBundleIdentifier`

不会生成可用的字头文件,我得到以下结果:

Does not generate a usable word header file, I get the following:


sdp:enumerator of enumeratione183:缺少必要的nameattribute.quote

sdp: enumerator of enumeration "e183": missing required "name" attribute.quote

论坛: https://discussions.apple.com/thread/2623068?start = 0& tstart = 0

然而,OP在尝试他的工作方式时却遇到了同样的问题,头文件。 OP建议使用以下操作:

Where the OP had the same issue, however, trying what he got to work, does not help, i.e. still no usable header file. OP recommended using the following:

sdef ./Microsoft\ Word.app/ > word.sdef 
cat word.sdef | sdp -fh --basename word

所以我想知道,如果有人有一个想法如何解决问题或者如果有其他方式从Microsoft Word发送和获取数据/信息。

So I wonder, if anyone has an idea how to fix the issue or if there is some other way to send and get data/info from Microsoft Word.

推荐答案

所以我找到了如何解决这个问题的Microsoft Word 2011 for Mac,我不是真的喜欢它,但它似乎工作。
解决方案基于我链接的讨论:

So I found out how to "solve" this issue for Microsoft Word 2011 for Mac, I don't really like it, but it seems to work. The "solution" is based on the discussion I linked:

这些命令在构建规则中运行,如描述,并显示在Apples示例中

The commands are run in the Build Rules, like described and show in Apples exampled (see my first comment for link).


  1. 首先使用命令 sdef$ INPUT_FILE_PATH> word.sdef (INPUT_FILE_PATH是Microsoft Word的路径,我已拖入XCode)

  2. 打开word.sdef文件并搜索枚举命名为e315和e183。
    枚举类似于:`
  3. e183缺少一个名称字段,因此我只是向其添加了一个字符串

  4. e315缺少其所有名称字段,因此我添加了它们

  5. 然后使用命令 cat word.sdef | sdp -fh -o$ DERIVED_FILES_DIR--basename$ INPUT_FILE_BASE

  6. 现在生成并可以使用Microsoft Word.h文件。 li>
  1. First use the command sdef "$INPUT_FILE_PATH" > word.sdef (INPUT_FILE_PATH is the path to Microsoft Word, which I've dragged into the XCode)
  2. Open the word.sdef file and search for the enumeration named e315 and e183. The enumeration looks like: `
  3. e183 is missing one name field, so I just added a string to it
  4. e315 is missing all its name fields, so I added them
  5. Then use the command cat word.sdef | sdp -fh -o "$DERIVED_FILES_DIR" --basename "$INPUT_FILE_BASE"
  6. A Microsoft Word.h file is now generated and can be used.

我不喜欢的解决方案,因为你必须手动添加字符串到.sdef文件,但是,它似乎工作。

I don't like the the solution, as you have to add strings to the .sdef file manually, however, it seems to work.

我会将其标记为正确答案,因为它解决了问题,但如果任何人有更好的解决方案,请告诉。

I'll mark it as correct answer, as it solves the issue, but if anyone has better solution do tell.

这篇关于脚本桥和生成Microsoft Word头文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆