SBApplication打开Microsoft Word文档

时间:2013-04-29 06:35:14

标签: objective-c macos cocoa scripting-bridge

我使用Apple讨论论坛的说明创建了头文件。但是我在指定路径中打开word文档时遇到了一些困难,但它只是创建了一个新文档而不是指定路径中的文档。我已粘贴下面的代码,用于打开word文档:

MicrosoftWordApplication *wordApp=[SBApplication
       applicationWithBundleIdentifier:@"com.microsoft.Word"];
wordApp.delegate = self;
[wordApp activate];

if([wordApp isRunning]) {
     MicrosoftWordDocument *activeWordDoc= [wordApp activeDocument];
    [wordApp setDefaultSaveFormat:@"Doc97"];
    [wordApp setDisplayRibbon:NO];
    NSLog(@"Filename = %@\nPath = %@",[activeWordDoc valueForKey:@"name"],[activeWordDoc path]);
}

这些代码可以帮助我打开我的本地文档

MicrosoftWordDocument *activeWordDoc= [wordApp activeDocument];
[activeWordDoc openFileName:@"file://localhost/Users/ramesh/Desktop/test.doc"
                 confirmConversions: FALSE
                           readOnly: FALSE
                   addToRecentFiles: FALSE
                   passwordDocument: @""
                   passwordTemplate: @""
                             Revert: FALSE
                      writePassword: @""
              writePasswordTemplate: @""
                      fileConverter:MicrosoftWordE162OpenFormatDocument97];

0 个答案:

没有答案