on getWordCustomDocumentPropertyWithDocumentID:(theDocumentID as string) andPropertyName:(thePropertyName as string)
--say "getWordCustomDocumentPropertyWithDocumentID:"
set myDocument to my getWordDocumentWithDocumentID:theDocumentID
tell application id "com.microsoft.Word"
set myValue to the value of (custom document properties of myDocument whose name is thePropertyName)
end tell
if myValue is not equal to missing value then
return myValue # here we don't know which class is myValue
end if
get my makeNewWordCustomDocumentPropertyWithDocumentID:(theDocumentID) andPropertyName:(thePropertyName) andPropertyValue:("*DEFAULT*")
tell application id "com.microsoft.Word"
set myValue to the value of (custom document properties of myDocument whose name is thePropertyName)
end tell
return myValue as string # here you "carefully" coerce myValue to a string
end getWordCustomDocumentPropertyWithDocumentID:andPropertyName:
Is the different treatment deliberate or is it an omission ?
You wrote that using
if myValue starts with "HIGH"
solves the problem. It's certainly right but it explain nothing. Look at these three cases.
set myValue to "HIGH" & return
myValue starts with "HIGH" --> true
set myValue to "HIGH" & space
myValue starts with "HIGH" --> true
set myValue to {"HIGH", "LOW"}
myValue starts with "HIGH" --> true
If you don't really identify what is wrong, you will face the problem again.
Yvan KOENIG running El Capitan 10.11.3 in French (VALLAURIS, France) mardi 15 mars 2016 16:12:30