私は経験豊富な Cocoa プログラマーであり、Applescript の初心者です。Microsoft ベースのレポート ジェネレーターをプログラムする必要があります。私は Applescript ブリッジから始めて、基本的に Word で壁にぶつかりました。私は今 ApplescriptObjC を試していますが、地獄のように苦労しています。
Objective-C で記述されたメソッドによってファイルのパスが報告されたときに、ファイルを開くというばかげた手順で立ち往生しています。Objective-C クラスのコードは非常に単純です (不自然な例として):
@implementation Reporter
- (NSString *)templatePath:(NSString *)fileName
{
NSString *fullPath = [self.currentDirectory stringByAppendingPathComponent:fileName];
return fullPath;
}
@end
補足: 現在のディレクトリは、ビルドされたアプリ ディレクトリではありません。これを使用しようとする私の試みの1つです:
on createReport()
set my myReporter to Reporter's alloc()'s init()
set WordApp to the application "Microsoft Word"
set FinderApp to the application "Finder"
set theWordTemplatePath to myReporter's templatePath:"Rapport.docx"
set theWordTemplatePath to theWordTemplatePath as text
tell FinderApp to open POSIX file theWordTemplatePath
end createReport
これはこのエラーを受け取ります:
*** -[CMDAppDelegate applicationWillFinishLaunching:]: Finder got an error: Can’t make «class ocid» id «data optr0000000080B00E0080600000» into type integer. (error -1700)
さまざまなバリエーションを試しましたが、何時間も試してみましたが、それでも Word でファイルを開くことができません。
私は何を間違っていますか?