Scripting bridge and generate Microsoft Word header file

怎甘沉沦 提交于 2019-12-31 03:01:26

问题


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 enumeration "e183": missing required "name" attribute.quote

From further search on Google, I found the following discussion on Apple forums: https://discussions.apple.com/thread/2623068?start=0&tstart=0

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

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.


回答1:


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:

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

  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.

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.



来源:https://stackoverflow.com/questions/15338454/scripting-bridge-and-generate-microsoft-word-header-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!