J
Jeanmcgru
Using Access ’03…
Doug Steele sent me some useful code to set a file attribute in VBA:
SetAttr "C:\Folder\File.mdb", GetAttr("C:\Folder\File.mdb") Or
vbHidden
I use the following code to copy a file from one location to another,
and then hide the file:
FileCopy SourceFile, DestinationFile
SetAttr "C:\Folder\File.mdb", vbHidden
This works fine, but it won’t let me do it twice and copy over the
preexisting file because the file is hidden.
I performed this workaround:
SetAttr "C:\Folder\File.mdb", vbNormal 'show file
FileCopy SourceFile, DestinationFile 'copy source file to destination
SetAttr "C:\Folder\File.mdb", vbHidden 'hide file
The code above works, but not the first time because the mdb does not
exist on the drive until the code runs at least once; i.e., I cannot
set an attribute on a file that does not exist.
I need to first check to see if the file exists, if so, then run the
first part of the code:
If File.mdb exists in C:\Folder Then
SetAttr "C:\Folder\File.mdb", vbNormal
Else
Nothing
End If
FileCopy SourceFile, DestinationFile
SetAttr "C:\Folder\File.mdb", vbHidden
Any ideas on how to check a location to see if a file exists?
alex
Doug Steele sent me some useful code to set a file attribute in VBA:
SetAttr "C:\Folder\File.mdb", GetAttr("C:\Folder\File.mdb") Or
vbHidden
I use the following code to copy a file from one location to another,
and then hide the file:
FileCopy SourceFile, DestinationFile
SetAttr "C:\Folder\File.mdb", vbHidden
This works fine, but it won’t let me do it twice and copy over the
preexisting file because the file is hidden.
I performed this workaround:
SetAttr "C:\Folder\File.mdb", vbNormal 'show file
FileCopy SourceFile, DestinationFile 'copy source file to destination
SetAttr "C:\Folder\File.mdb", vbHidden 'hide file
The code above works, but not the first time because the mdb does not
exist on the drive until the code runs at least once; i.e., I cannot
set an attribute on a file that does not exist.
I need to first check to see if the file exists, if so, then run the
first part of the code:
If File.mdb exists in C:\Folder Then
SetAttr "C:\Folder\File.mdb", vbNormal
Else
Nothing
End If
FileCopy SourceFile, DestinationFile
SetAttr "C:\Folder\File.mdb", vbHidden
Any ideas on how to check a location to see if a file exists?
alex