0

I'm developing an application which needs to work with the Apple version of MS-Word using Scripting Bridge . I need to call a command of MS-Word defined in its sdef file but I can't figure out how to do it.

The definition of the command in the sdef file

<command name="reset" code="sTXTmFBr" description="Removes paragraph formatting that differs from the underlying style. For example, if you manually right align a paragraph and the underlying style has a different alignment, the reset method changes the alignment to match the style formatting.">
    <direct-parameter type="4046"/>
</command>

and its definition in the header file

@interface WordApplication : SBApplication
...
- (void) reset:(Word4046)x;  // Removes paragraph formatting that differs from the underlying style. For example, if you manually right align a paragraph and the underlying style has a different alignment, the reset method changes the alignment to match the style formatting.
...
@end

The definition of the type of the direct-parameter in the sdef file:

<enumeration name="4046" code="4046">
    <enumerator name="paragraph" code="cpar"/>
    <enumerator name="paragraph format" code="w136"/>
</enumeration>

and its definition in the header file

enum Word4046 {
    Word4046Paragraph = 'cpar',
    Word4046ParagraphFormat = 'w136'
};
typedef enum Word4046 Word4046;

The definition of the class of the object I want to reset:

<class name="paragraph format" code="w136" description="Represents all the formatting for a paragraph." inherits="base object" plural="paragraph formats">
...
</class>

and its definition in the header file

// Represents all the formatting for a paragraph.
@interface WordParagraphFormat : WordBaseObject
...
@end

The only way my app compiles and doesn't crash is:

WordApplication *sbApplication; // SBObject which represents Word App
WordParagraphFormat *sbParagraph; // SBObject which represents a paragraph format
[sbApplication reset:Word4046ParagraphFormat]

but it obviously does nothing because I'm not specifying the object I want to reset but the type of that object.

How can I reset the sbParagraph object?

Thanks.

Emilio
  • 393
  • 1
  • 2
  • 11
  • I'm not familiar with the objective-c side of this to give you an Answer, but to identify a particular paragraph you basically an index into the collection of paragraphs for an object that contains paragraphs (e.g. a range, the selection etc.). e.g. to reset the 2nd paragraph in the document body of the active document you could use applescript such as 'tell application "Microsoft Word" to reset paragraph 2 of the active document'. Does that help? –  Sep 01 '14 at 19:07
  • The funny thing is that command simply doesn't have a parameter to specify a paragraph. Do you know how to make it work in AppleScript? If so, it's generally possible to translate that to Scripting Bridge, but it may not be pretty — SB doesn't work well with commands that rely on AppleScript-specific constructs, or that just plain lie. – Chris N Dec 08 '14 at 17:04

0 Answers0