Results 1 to 5 of 5
  1. #1
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    BuiltInDocumentProperties('Last Print Date') (word

    The code below (and code like it) generates an Automation Error when the active document is one which has never been printed.

    I can't work out a suitable test for the aberration, and I hate the on-error business with a passion.

    I'd sure appreciate any clues as to how to detect a blank/null/empty property here.


    <pre>Sub test1()
    MsgBox ActiveDocument.BuiltInDocumentProperties("Creation Date")
    MsgBox ActiveDocument.BuiltInDocumentProperties("Last Save Time")
    MsgBox ActiveDocument.BuiltInDocumentProperties("Total Editing Time")
    MsgBox ActiveDocument.BuiltInDocumentProperties("Last Print Date")
    End Sub
    </pre>


  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: BuiltInDocumentProperties('Last Print Date') (word

    Chris,
    Have you tried:
    isdate(Activedocument.BuiltInDocumentProperties("L ast Print Date"))
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: BuiltInDocumentProperties('Last Print Date') (word

    Help says "Note -- If Microsoft Word doesn't define a value for one of the built-in document properties, reading the Value property for that document property generates an error." Translation: always use OnError (we mean it)!

    Like you, I don't like to use OnError, but it has seemed to be nessary with most of my DocProperties code. --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  4. #4
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: BuiltInDocumentProperties('Last Print Date') (

    Give this man another award. And a ceremony to go with it. And a date.!

    <font color=red>Thanks, Rory</font color=red>, this is a VBA test that is not an On Error thingy.

    I must me away and get, for once and for all, a list of the IS things. IsNull I know, IsMissing, now IsDate.


    (I was once stood up for a date; I could have used a combination of IsDate IsMissing IsNull to console mysyelf ...)

  5. #5
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: BuiltInDocumentProperties('Last Print Date') (

    Sam, thanks. I agree with you that On Error does get to be necessary at times. I found a case about six months ago where quite obviously there's be no way around the situation without an On Error.

    That said, I avoid it as much as possible.

    On Error always seems to me like "programming for the things I was too lazy to anticipate". i know it's not always that way, but it seems like it in other people's code sometimes.


    Now in my example (dates), it may well be that i can't handle null dates, so Rory's test may end up effecting the same thing as an On Error woul (aka throwing up hands and using a date of 0000/00/00) but at least with the IsDate function it looks as if I lknow what I'm programming about.



    'Twould be interesting to build a list of those VBA situations where there really is no way except to use On Error.

    Also I learning to take the Help files with a Kg of NaCl.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •