问题
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).
- 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) - Open the word.sdef file and search for the enumeration named e315 and e183. The enumeration looks like: `
- e183 is missing one name field, so I just added a string to it
- e315 is missing all its name fields, so I added them
- Then use the command
cat word.sdef | sdp -fh -o "$DERIVED_FILES_DIR" --basename "$INPUT_FILE_BASE"
- 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