I am an experienced Cocoa programmer and an Applescript newbie. I need to program a Microsoft-based report generator. I started with the Applescript bridge and basically hit a wall with Word. I am now trying with ApplescriptObjC, and I am struggling like hell.
I am even stuck in the stupid step of opening a file when its path is reported by a method written in Objective-C. The objective-C class code is very simple (as a contrived example):
@implementation Reporter
- (NSString *)templatePath:(NSString *)fileName
{
NSString *fullPath = [self.currentDirectory stringByAppendingPathComponent:fileName];
return fullPath;
}
@end
Side Note: the current directory is not the built app directory. Here is one of my tries to use it:
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
This one gets this error:
*** -[CMDAppDelegate applicationWillFinishLaunching:]: Finder got an error: Can’t make «class ocid» id «data optr0000000080B00E0080600000» into type integer. (error -1700)
I tried many variations, and despite many hours trying, I still can't have Word open my file.
What am I doing wrong?