Problem getting Standard Doc Properties in Word 2011
Problem getting Standard Doc Properties in Word 2011
- Subject: Problem getting Standard Doc Properties in Word 2011
- From: Dave <email@hidden>
- Date: Mon, 14 Mar 2016 19:15:32 +0000
Hi All,
Can anyone see what could be wrong with the following Script when run from an AppleScript-ObjC handler in an XCode Project.
This seems to work ok if I run it in the Script Editor, but if I Run it from my XCode Project, then getWordDocumentWithDocumentID fails to find return the document for the ID.
The Document ID is the Full Name of the Document as a POSIX Path. The outside world wants the this ID as a POSIX Path, but when I want to do something with it inside the a Script Handler I want the Mac Path, so I convert between the two. But if I run from from XCode this seems to fail?
Also how can I log from with in AppleScript-ObjC Handler?
Thanks in Advance for any Help
Dave
-----------------------------------------------
on getPOSIXPathWithMacPath:(theMacPath)
set myFullNamePOSIX to the POSIX path of theMacPath
return myFullNamePOSIX
end getPOSIXPathWithMacPath:
on getMacPathWithPOSIXPath:(thePOSIXPath as string)
--say "getMacPathWithPOSIXPath:" & thePOSIXPath
set myMacPath to POSIX file thePOSIXPath
return myMacPath
end getMacPathWithPOSIXPath:
on getWordDocumentWithDocumentID:(theDocumentID as string)
say "getWordDocumentWithDocumentID: " & theDocumentID
say "Get Doc 1"
tell application id "com.microsoft.Word"
set myDocumentID to my getMacPathWithPOSIXPath:(theDocumentID)
set myDocumentList to (every document whose full name is myDocumentID)
say "Get Doc 2"
if myDocumentList = {} then
beep
return missing value
end if
say "Get Doc 3 - Count: " & the count of myDocumentList —COUNT is equal to Zero!!!!!!!!!!!!!!!
set myDocument to item 1 of myDocumentList
end tell
say "Get Doc 4"
return myDocument
end getWordDocumentWithDocumentID:
on getWordStandardDocumentPropertyWithDocumentID:(theDocumentID as string) andPropertyName:(thePropertyName as string)
--say "getWordStandardDocumentPropertyWithDocumentID: " & theDocumentID
set myDocument to my getWordDocumentWithDocumentID:(theDocumentID)
say "Get Prop 1"
tell application id "com.microsoft.Word"
set myValue to the value of (document properties of myDocument whose name is thePropertyName)
end tell
say "Get Prop 2"
return myValue
end getWordStandardDocumentPropertyWithDocumentID:andPropertyName:
on getWordStandardDocumentDictionaryWithDocumentID:(theDocumentID as string)
say "getWordStandardDocumentDictionaryWithDocumentID:" --& theDocumentID
set myStandardDocumentPropertiesDictionary to my newWordStandardDocumentDictionary()
say "Test 1"
tell application id "com.microsoft.Word"
--
-- Set Up the Message Properties Dictionary
--
set kDocumentID of myStandardDocumentPropertiesDictionary to theDocumentID
say "Test 2"
set kDocumentTitle of myStandardDocumentPropertiesDictionary to my getWordStandardDocumentPropertyWithDocumentID:theDocumentID andPropertyName:"Title"
set kDocumentSubject of myStandardDocumentPropertiesDictionary to my getWordStandardDocumentPropertyWithDocumentID:theDocumentID andPropertyName:"Subject"
set kDocumentAuthor of myStandardDocumentPropertiesDictionary to my getWordStandardDocumentPropertyWithDocumentID:theDocumentID andPropertyName:"Author"
set kDocumentKeywords of myStandardDocumentPropertiesDictionary to my getWordStandardDocumentPropertyWithDocumentID:theDocumentID andPropertyName:"Keywords"
set kDocumentComments of myStandardDocumentPropertiesDictionary to my getWordStandardDocumentPropertyWithDocumentID:theDocumentID andPropertyName:"Comments"
set kDocumentTemplate of myStandardDocumentPropertiesDictionary to my getWordStandardDocumentPropertyWithDocumentID:theDocumentID andPropertyName:"Template"
set kDocumentLastAuthor of myStandardDocumentPropertiesDictionary to my getWordStandardDocumentPropertyWithDocumentID:theDocumentID andPropertyName:"Last author"
set kDocumentRevisionNumber of myStandardDocumentPropertiesDictionary to my getWordStandardDocumentPropertyWithDocumentID:theDocumentID andPropertyName:"Revision number"
set kDocumentApplicationName of myStandardDocumentPropertiesDictionary to my getWordStandardDocumentPropertyWithDocumentID:theDocumentID andPropertyName:"Application name"
set kDocumentLastPrintDate of myStandardDocumentPropertiesDictionary to my getWordStandardDocumentPropertyWithDocumentID:theDocumentID andPropertyName:"Last print date"
set kDocumentCreationDate of myStandardDocumentPropertiesDictionary to my getWordStandardDocumentPropertyWithDocumentID:theDocumentID andPropertyName:"Creation date"
set kDocumentLastSaveTime of myStandardDocumentPropertiesDictionary to my getWordStandardDocumentPropertyWithDocumentID:theDocumentID andPropertyName:"Last save time"
set kDocumentTotalEditingTime of myStandardDocumentPropertiesDictionary to my getWordStandardDocumentPropertyWithDocumentID:theDocumentID andPropertyName:"Total editing time"
set kDocumentNumberOfPages of myStandardDocumentPropertiesDictionary to my getWordStandardDocumentPropertyWithDocumentID:theDocumentID andPropertyName:"Number of pages"
say "Test 50"
set kDocumentNumberOfWords of myStandardDocumentPropertiesDictionary to my getWordStandardDocumentPropertyWithDocumentID:theDocumentID andPropertyName:"Number of words"
set kDocumentNumberOfCharacters of myStandardDocumentPropertiesDictionary to my getWordStandardDocumentPropertyWithDocumentID:theDocumentID andPropertyName:"Number of characters"
set kDocumentSecurity of myStandardDocumentPropertiesDictionary to my getWordStandardDocumentPropertyWithDocumentID:theDocumentID andPropertyName:"Security"
set kDocumentCategory of myStandardDocumentPropertiesDictionary to my getWordStandardDocumentPropertyWithDocumentID:theDocumentID andPropertyName:"Category"
set kDocumentFormat of myStandardDocumentPropertiesDictionary to my getWordStandardDocumentPropertyWithDocumentID:theDocumentID andPropertyName:"Format"
set kDocumentManager of myStandardDocumentPropertiesDictionary to my getWordStandardDocumentPropertyWithDocumentID:theDocumentID andPropertyName:"Manager"
set kDocumentCompany of myStandardDocumentPropertiesDictionary to my getWordStandardDocumentPropertyWithDocumentID:theDocumentID andPropertyName:"Company"
set kDocumentNumberOfBytes of myStandardDocumentPropertiesDictionary to my getWordStandardDocumentPropertyWithDocumentID:theDocumentID andPropertyName:"Number of bytes"
set kDocumentNumberOfLines of myStandardDocumentPropertiesDictionary to my getWordStandardDocumentPropertyWithDocumentID:theDocumentID andPropertyName:"Number of lines"
set kDocumentNumberOfParagraphs of myStandardDocumentPropertiesDictionary to my getWordStandardDocumentPropertyWithDocumentID:theDocumentID andPropertyName:"Number of paragraphs"
set kDocumentNumberOfSlides of myStandardDocumentPropertiesDictionary to my getWordStandardDocumentPropertyWithDocumentID:theDocumentID andPropertyName:"Number of slides"
set kDocumentNumberOfNotes of myStandardDocumentPropertiesDictionary to my getWordStandardDocumentPropertyWithDocumentID:theDocumentID andPropertyName:"Number of motes"
set kDocumentNumberOfHiddenSlides of myStandardDocumentPropertiesDictionary to my getWordStandardDocumentPropertyWithDocumentID:theDocumentID andPropertyName:"Number of hidden slides"
set kDocumentNumberOfMultiMediaClips of myStandardDocumentPropertiesDictionary to my getWordStandardDocumentPropertyWithDocumentID:theDocumentID andPropertyName:"Number of multimedia clips"
set kDocumentHyperlinkBase of myStandardDocumentPropertiesDictionary to my getWordStandardDocumentPropertyWithDocumentID:theDocumentID andPropertyName:"Hyperlink base"
end tell
say "Test 100"
return myStandardDocumentPropertiesDictionary as record
end getWordStandardDocumentDictionaryWithDocumentID:
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden