It looks like you're mostly having trouble getting a document reference - the innermost code you have looks fine (though eventually I'm sure you'll want to see if your resource (me!) already exists in your document).
You say the document already exists? Let's say for the moment that you know it's already populated with resources. Try something like this:
Code:
tell application "OmniPlan"
open "::Users:tom:foo.omniplan"
set myDoc to document "foo"
tell myDoc
set Myself to first resource whose name is "Tom"
set MyTask to make new task with properties {name:"Cure Cancer", duration:8.0}
assign MyTask to Myself
end tell
end tell
Honestly, I'm not sure how to write something like
Code:
if Myself is null then
set Myself to make new resource with properties {kind:person, efficiency:2, name:"Tom", cost per hour:200.0}
end if
So I'm secretly hoping you won't ask. The above definitely won't work.
-Tom