Solved

VBA Check Folders

Posted on 2013-11-11
5
350 Views
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 -
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_28162861.html

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 :)

Thanks
0
Comment
Question by:Rayne
  • 3
  • 2
5 Comments
 
LVL 10

Assisted Solution

by:broro183
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 www.excelguru.ca/node/30 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
EarlyExit:
    On Error GoTo 0
End Function

Open in new window


hth
Rob
0
 
LVL 10

Accepted Solution

by:
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...
else
'folder doesn't exist therefore...
msgbox "Folder doesn't exist"
end if

Open in new window


hth
Rob
0
 

Author Comment

by:Rayne
ID: 39638377
AWESOME Rob,
This is exactly what I needed :)
Thank you...
0
 
LVL 10

Expert Comment

by:broro183
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 :-)
Rob
0
 

Author Comment

by:Rayne
ID: 39640631
Thank you Rob, I will check that  and let you know.
Meanwhile, here is a question if that interest you
http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Q_28291518.html
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

830 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