+ Reply to Thread
Results 1 to 8 of 8

setting file attributes on close

  1. #1
    Registered User
    Join Date
    04-27-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    18

    Thumbs up setting file attributes on close

    Hello,

    I am wondering how I can write a macro to set file attributes to hidden/read only, when I close it. Any tips are welcome. Thank you in advance.
    Last edited by Karolis; 09-21-2010 at 03:23 AM.

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: setting file attributes on close

    After closing:

    Please Login or Register  to view this content.
    Last edited by snb; 09-20-2010 at 09:44 AM.



  3. #3
    Registered User
    Join Date
    04-27-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    18

    Re: setting file attributes on close

    sorry, i'm not very great with excel. where do i have to put this in vba? in workbook general?

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: setting file attributes on close

    Put this code in the 'ThisWorkbook module in teh VBEditor (alt-F11)
    The file will be Hidden & Readonly.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-27-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    18

    Thumbs up Re: setting file attributes on close

    Thanx I was about to post that I figured it out already. Just one more question:
    attributes = 1 file is read only
    attributes = 2 file is hidden
    attributes = 3 file is read only and hidden.
    Am I correct? and is there more options?

  6. #6
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: setting file attributes on close

    You are correct, more options you'll find in the VBEditor's help, look for 'attributes'.

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: setting file attributes on close

    Please Login or Register  to view this content.
    Note that a reference is required.

    Examples:

    Please Login or Register  to view this content.
    See VBE help for Attributes Property for a list
    Last edited by shg; 09-21-2010 at 08:45 AM.
    Entia non sunt multiplicanda sine necessitate

  8. #8
    Registered User
    Join Date
    04-27-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    18

    Thumbs up Re: setting file attributes on close

    Thank you very much for your help! This is solved!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1