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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Case insensitive use of Chdir 2

Status
Not open for further replies.

phudgens

Technical User
Jul 8, 2004
117
US
How can I make the following VBA code case insensitve:

Set SF = Folders.SubFolders
For Each F1 In SF
If F1 = ThisWellPath & "\Deliverables" Then DelFolder = True


If the Deliverables folder is not spelled exactly as shown (as far as case is concerned), the program will not find the folder. I need code that can find a Deliverables folder regardless of case. (ie deliverables, or DELIVERABLES). Once I’ve determined that the folder exists, how can I use Chdir to change to that folder?

Thanks,

Paul Hudgens
Denver
phudgens@denver.oilfield.slb.com
 
You can convert the string to upper case or lower

[tab]If StrConv(F1, vbUpperCase) = ...
or
[tab]If StrConv(F1, vbLowerCase) = ...


(I'm assuming that F1 is not a cell reference)


[tt][blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ 181-2886 before posting.
 
If LCase(F1.Name) = "deliverables" Then DelFolder = True

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks guys - this is helpful. However, I'm wondering how I will use Chdir to change to the "deliverables" folder once I've determined that it exists, keeping in mind that there could be any of many permutations and combinations of upper/lower case in the folder name. For example, I've already run in to one instance where the user had named the folder "DEliverables". Using Chdir to change to "Deliverables" would in this case fail.

Thanks,
Paul Hudgens
 
would in this case fail
I don't think so as ChDir should be case insensitive.
 
I have definitely seen circumstances where case mattered, altough in other cases it seemed not to matter. I'm not sure what to believe. I have however, tried the following code and it works:

Set SF = Folders.SubFolders
For Each F1 In SF
If LCase(F1.Name) = "deliverables" Then
DelFolder = True
DelFolderName = F1.Name
End If
...

where DelFolderName is dimmed as a string. Chdir can then be used with DelFolderName.

Thanks,
Paul H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top