473,387 Members | 1,683 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Look for specific folder in all existing subfolders in main directory

3
Hi everyone,

I'm looking for a vba script which opens a subfolder in a maindirectory with only a part of the name known. I found something similar for files :

http://bytes.com/topic/visual-basic/answers/827411-searching-main-folder-all-sub-folders-file

example : c:\numbers\cars\10 big
c:\numbers\caravans\15 big

If I fill in 15 and c:\numbers as maindirectory in vba the script should open the 15 big folder since 15 is in the name
Nov 7 '13 #1
3 1420
9815402440
180 100+
following code may help you
Expand|Select|Wrap|Line Numbers
  1.     Dim strT As String
  2.     strT = Dir("c:\", vbDirectory)
  3.     While strT <> Empty
  4.         If InStr(1, strT, "w", vbTextCompare) > 0 Then
  5.             Debug.Print strT
  6.         End If
  7.         strT = Dir()
  8.     Wend
  9.  
Nov 7 '13 #2
gehawk
3
your code shows me the result in the immediate window.
Could you advise me how to proceed? I only know some basic vba programming
Nov 8 '13 #3
gehawk
3
Is this getting anywhere?

Expand|Select|Wrap|Line Numbers
  1. Dim f As Boolean
  2.  
  3. Sub AAA()
  4.     Dim FSO As Scripting.FileSystemObject
  5.     Dim FF As Scripting.Folder
  6.     f = False
  7.     Set FSO = New Scripting.FileSystemObject
  8.     Set FF = FSO.GetFolder("C:\Users\<username>\Desktop\testje")
  9.     DoOneFolder FF
  10.     If Not f Then
  11.         MsgBox "File not found!", vbExclamation
  12.     End If
  13. End Sub
  14.  
  15. Sub DoOneFolder(FF As Scripting.Folder)
  16.  
  17.     Dim SubF As Scripting.Folder
  18.     Dim strPath As String
  19.     Dim strFile As String
  20.     On Error GoTo ExitHandler
  21.     If f Then Exit Sub
  22.     strPath = FF.Path
  23.  
  24.     If Left(strPath, 1) <> "15" Then
  25.         strPath = strPath & "\"
  26.     End If
  27.  
  28.     For Each SubF In FF.SubFolders
  29.         If Left(strPath, 1) = "15" Then
  30.         Call Shell("explorer.exe " & strPath, vbNormalFocus)
  31.         DoOneFolder SubF
  32.     Next SubF
  33. ExitHandler:
  34. End Sub
I found a code online and tried to adjust it
Nov 8 '13 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: ALI-R | last post by:
how can I get a list of file names in an specific folder? thanks
6
by: joey.powell | last post by:
I am working on a windows forms app where I need to do copies. I also need to show a progress bar. In order to be able to set the Maximum property for the progress bar and then update it during the...
8
by: Paw | last post by:
Greetings. I use asp. what I need is is when a visitor comes to the site, I need it to check the host name. if "www.hometowndigest.com" is the host, then check a folder named "something" and if...
1
by: nafogel | last post by:
Hi, I am kinda familiar with html, but i am having a problem. I am working on a menu system for a handheld gaming device (PSP). I want the menu to be able to display all files with a certain...
9
by: freduchi | last post by:
Hi, I need sugestions. I need to implement the next and I donīt know how to do it: I am developing a website in which users are signed up and share information(Messages, Photos...). When a...
2
jaccess
by: jaccess | last post by:
I was wondering if there is a simple way to open a specific folder from an access form button. I have a form that a user can enter a date range and either view or print reports based on the date...
5
by: Alice | last post by:
I'm trying to upload all .txt files from a specific folder using the following code, but it didn't work. HELP The problem lies in DoCmd.TransferText acImportFixed, "Imperial Import...
6
by: ManagedCoder | last post by:
Hi, My requirement is as follows: I need to set the HttpExpires (enable content expiration - set to 7 days) on a folder within a virtual directory. I have been able to set the HttpExpires...
1
by: mpetter | last post by:
Hi guys ! How Can I Create a contact item(Outlook 2003) in specific folder under default folder? I have this situation: Set myolApp = CreateObject("Outlook.Application") Set myNameSpace =...
3
by: Ned White | last post by:
Hi All, I would like to create a httphandler to set text watermark on image files before it gets displayed to the user. But this handler must listen specific folder or virtual directory(on same...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.