• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Word - How to Access Custom Document Properties
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Word - How to Access Custom Document Properties


  • Subject: Re: Word - How to Access Custom Document Properties
  • From: Christopher Stone <email@hidden>
  • Date: Tue, 03 Nov 2015 06:57:50 -0600

On Nov 03, 2015, at 04:36, Dave <email@hidden> wrote:
I’m trying to write a script that checks if a number of Custom Document Properties have been set and if so, do something with the Value field, but I can’t figure how to access them in AppleScript.

Why does this give an error on the repeat line?
______________________________________________________________________

Hey Dave,

Possibly because your document has NO custom properties?

Always back up to your likely sticking point and either comment-out the subsequent code or use a return result statement to break where you want to look.

Or you can be more specific and return a specific value: return customDocProperties.

You'll see right quick that a blank document will return missing value, because it has NO custom properties.

A loop with a missing value will error.

Here are some working bits (existing properties are required):

-----------------------------------------------------------------
# dNam: Microsoft Word 14.5.7 » Custom Document Properties
# dMod: 2015/11/03 05:04 
-----------------------------------------------------------------
tell application id "com.microsoft.Word"
  set myDocument to active document

  

  tell myDocument
    set customDocProperties to custom document properties

    

    if customDocProperties ≠ missing value then
      repeat with i in customDocProperties
        set {propName, propValue} to {name, value} of i
      end repeat

      

      # OR

      

      tell custom document properties
        set customPropNameList to name
        set customPropValueList to value
      end tell

      

      # OR

      

      set value of (custom document properties whose name is "Department") to "File Thirty"

      

    else
      error "The front Word document has NO custom properties!"
    end if

    

  end tell
end tell
-----------------------------------------------------------------

After quite a bit of effort and research I find no working method of CREATING or DELETING custom document properties – despite the fact that make and delete are listed in the sdef for them.

While it's certainly possible that I'm missing the correct syntax, I've tried out everything reasonable.  My conclusion in the absence of other evidence is that these functions are broken.

I'm peeved that Word 2011 won't take a VB string, because VB will create these with no problem.

AppleScript can run an existing macro though, so if you need to populate custom properties you can set up one or more VB macros and call them by name.

You can then change their values with AppleScript.

--
Best Regards,
Chris

 _______________________________________________
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

  • Follow-Ups:
    • Re: Word - How to Access Custom Document Properties
      • From: Dave <email@hidden>
References: 
 >Word - How to Access Custom Document Properties (From: Dave <email@hidden>)

  • Prev by Date: Calendar - the big hangover
  • Next by Date: Re: Word - How to Access Custom Document Properties
  • Previous by thread: Word - How to Access Custom Document Properties
  • Next by thread: Re: Word - How to Access Custom Document Properties
  • Index(es):
    • Date
    • Thread