Results 1 to 4 of 4

Thread: Set Attr (XP)

  1. #1
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Set Attr (XP)

    We know that the following VBA code will change the file attributes. vbNormal in this case would reset both ReadOnly and Hidden. Is it possible to only set ReadOnly to False and leave Hidden as True?

    SetAttr "C:instructions.doc", vbNormal (would set the file to Normal )
    SetAttr "C:instructions.doc", vbReadOnly + vbHidden (would set the file to ReadOnly and Hidden )

    Thanks,
    John

  2. #2
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Set Attr (XP)

    I think as simple as:

    SetAttr "C:instructions.doc", vbNormal + vbHidden
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Set Attr (XP)

    Or even

    SetAttr "C:instructions.doc", vbHidden

    (vbNormal is 0, so you can omit it if you're setting another attribute)

  4. #4
    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: Set Attr (XP)

    If you only want to remove ReadOnly and leave whatever other attributes have been set:
    <code>setattr "C:instructions.doc", getattr("C:instructions.doc") and not vbreadonly</code>
    Regards,
    Rory

    Microsoft MVP - Excel

Posting Permissions

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