Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting only .IPT files using filesystemobject

Status
Not open for further replies.

stibbetts

Technical User
May 6, 2004
64
US
i am using filesystemobject to list some files that i am going to perform some operations on, the issue i am having is that the filesystemobject method of doing this comes up with the 5 files that i put in the referenced folder as well as a couple hidden or system files (im not sure which or even if it is one of these) its these "extra" files that throw off my file count and make the whole operation go !!kablamo!! and not work. please help, how do i specify only to get an .ipt file?
 
Use the FileSystemObjects .GetExtensionName method to determine if each file is one you want to process or not.

[blue]"Well, once again my friend, we find that science is a two headed beast. One head is nice, it gives us aspirin and other modern conveniences,...but the other head of science is BAD! Oh, beware the other head of science, Arthur; it bites!!" - The Tick[/blue]
 
stibbetts, can you please post the code where you get the list of files, so we can help you with your code ?
The basic idea is something like this:
If UCase(Right(objFile.Name, 4)) = ".IPT" Then

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Or
If UCase(oFSO.GetExtensionName(objFileName)) = "IPT" Then

[blue]"Well, once again my friend, we find that science is a two headed beast. One head is nice, it gives us aspirin and other modern conveniences,...but the other head of science is BAD! Oh, beware the other head of science, Arthur; it bites!!" - The Tick[/blue]
 
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(IPTPath3)
Set fc = f.files
For Each f1 In fc
chkbxnumber = rep + (rep1 * iptqty)
TemplateFilePath = IPTPath3 & f1
If GetCheck("CheckBox" & chkbxnumber) = True Then
Debug.Print (TemplateFilePath)
End If
rep = rep + 1
End If
Next
 
Use this or make the same change using PHV's solution. Either should work:
Code:
Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFolder(IPTPath3)
    Set fc = f.files
    For Each f1 In fc
        If UCase(fs.GetExtensionName(f1.Name)) = "IPT" Then        
            chkbxnumber = rep + (rep1 * iptqty)
            TemplateFilePath = IPTPath3 & f1
            If GetCheck("CheckBox" & chkbxnumber) = True Then
                Debug.Print (TemplateFilePath)
            End If
            rep = rep + 1
        End If
    Next

[blue]"Well, once again my friend, we find that science is a two headed beast. One head is nice, it gives us aspirin and other modern conveniences,...but the other head of science is BAD! Oh, beware the other head of science, Arthur; it bites!!" - The Tick[/blue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top