Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VBA Check Folders

Posted on 2013-11-11
5
Medium Priority
?
396 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Microsoft has changed the look and feel of Azure AD and Microsoft account sign-in pages so that you will have a more unified look and feel when moving between the two interfaces.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

688 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