Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VBA Check Folders

Posted on 2013-11-11
5
Medium Priority
?
410 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 2000 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 2000 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Ever wonder what it's like to get hit by ransomware? "Tom" gives you all the dirty details first-hand – and conveys the hard lessons his company learned in the aftermath.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

885 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