Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
When you add 34 to set the archive and hidden attributes, you should check
first that they are not already set, otherwise you distort it. Do x = x Or 34 I don't think the problem is with attributes, but do you understand what AND and OR does? If x And (vbArchive Or vbHidden) Then _ MsgBox "vbArchive and vbHidden" -- HTH RP (remove nothere from the email address if mailing direct) wrote in message oups.com... Hi Bob, There seems to be something strange with the Attribute property ... Put this code in a new workbook: Sub test() x = GetAttr(Range("A1").Parent.Parent.FullName) x = x + 34 ' Set Archive & Hidden attribute If x = vbNormal Then MsgBox "vbNormal" ' Note, AND doesn't work! If x And vbArchive = vbArchive Then MsgBox "vbArchive" If x And vbHidden Then MsgBox "vbHidden" If x And vbArchive And x And vbHidden Then MsgBox "vbArchive and vbHidden" If x And vbArchive = vbArchive And x And vbHidden = vbHidden Then MsgBox "vbArchive and vbHidden" x = 0 ' Clear Archive & Hidden attributes If x = vbNormal Then MsgBox "vbNormal" ' Note, AND doesn't work! If x And vbArchive Then MsgBox "vbArchive" If x And vbHidden Then MsgBox "vbHidden" End Sub It seems OK, apart from the 4th If statement, which doesn't work (whereas the 5th one does), which I don't understand. What's more, when I apply the 4th If statement to the attribute property of a file derived via the FileSystemObject, it actually says that NO files meet the requirements, and the 5th one says that ALL meet the requirements! This has got me. It sure looks like another Excel object model oddity. The workbook that I have the full FileSystemObject is rather large, so I can't paste the code. I could e-mail it off-line if you're interested ..... Cheers, Mark |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Data value display attributes linked to table attributes | Charts and Charting in Excel | |||
Getting NTFS file attributes | Excel Discussion (Misc queries) | |||
Filecopy, file attributes | Excel Programming | |||
File Attributes | Excel Discussion (Misc queries) | |||
file attributes via macro | Excel Programming |