• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Is there a way to check if the path entered by a user is valid.

ThrottleWorks

Excel Ninja
Hi,

I have provided an option in macro to save the output report at a predefined path.

File name is saved at a different cell.

My doubt is, is there any way to check if the path entered by a user in an excel cell in valid.

I do know how to do it, can anyone please help me in this.

Please note - This is not urgent.

Code used (taken from this Forum only) by me to save the file.

Application.DisplayAlerts = False

ActiveWorkbook.SaveAs Filename:=MacroSht.Range("A1").Value & "\" & MacroSht.Range("B1").Value & ".xls", FileFormat:=xlNormal

MacroBook.Close

Application.DisplayAlerts = True
 
I usually set an On Error Do Something style line
just before accessing a file or directory
That way if the directory doesn't exist you keep control of the process, ie: go back and ask for them to try again
 
In this code we have too control on process...

Code:
re:

'some code


If Not Len(Dir$(MacroSht.Range("A1").Value, vbDirectory)) > 0 Then
    MsgBox "Path not found", vbCritical: Exit Sub: GoTo re
End If
 
Back
Top