VBA Check Folders

Posted on 2013-11-11
Last Modified: 2013-11-11
Hello All,

Can anyone help with how to do this? This is in reference to the solution of this previous question -

How do i do this in VBA - so that first the code checks for the folder that exists. Then is continues the code that is after this checking.

All experts are welcome :)

Question by:Rayne
  • 3
  • 2
LVL 10

Assisted Solution

broro183 earned 500 total points
ID: 39638363
hi Rayne,

I can't tell from the previous (linked) question which suggestion of Aikimark's you are using to refresh your drives.

I'm not sure if I fully understand this question so this comment may or may not provide an answer for you.

To check that a file or folder exists I normally use the below function. I can't remember if it works for files stored on SharePoint.

Public Function DoesFileFolderExist(strfullpath As String) As Boolean
'25/10/2010, RB: sourced from by Ken Puls
'note it only checks for the existence of the lowest folder (or the file) in the strfullpath string.
    On Error GoTo EarlyExit
    If Not Dir(strfullpath, vbDirectory) = vbNullString Then DoesFileFolderExist = True
    On Error GoTo 0
End Function

Open in new window

LVL 10

Accepted Solution

broro183 earned 500 total points
ID: 39638370
This can be implemented using something like:

if DoesFileFolderExist("change as required to the Folder name") then
'code if folder exists...
'folder doesn't exist therefore...
msgbox "Folder doesn't exist"
end if

Open in new window


Author Comment

ID: 39638377
This is exactly what I needed :)
Thank you...
LVL 10

Expert Comment

ID: 39638434
hi Rayne,

I'm pleased I could help - please let me know if it does work with Sharepoint locations.

Thanks for the points :-)

Author Comment

ID: 39640631
Thank you Rob, I will check that  and let you know.
Meanwhile, here is a question if that interest you

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

No matter the version of Windows you are using, you may have some problems with Windows Search running too slow or possibly not running at all. Before jumping into how you can solve this issue, just know there are many other viable alternative deskt…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now