Hi there,

I am new to coding of all kinds and have run into problems when trying to write a script to do the following in Excel 2010. I have been googling for the last couple of days and have not been able to find an answer, so would appreciate your help!

I’m making a macro that will check to see if a folder exists and do one of two things, depending on the result:
1: Create the folder if it doesn’t exist, and/or
2: Show the folder if it does exist

This is my code so far:
Code:
Dim sPath As String

sPath = "H:\My Documents\Prospects\" + Cells(ActiveCell.Row, 39).Value + "\" + Cells(ActiveCell.Row, 1).Value

‘Create the folder if it doesn’t exist
If Len(Dir(sPath)) = 0 Then
   MkDir sPath
End If

‘Show the folder if it exists
If Len(Dir(sPath)) = True Then
retVal = Shell("explorer.exe " & sPath, vbNormalFocus)
End If
Both parts of the code run fine if separated into two macros, by removing the If Then statements. However, I can’t get it to run as one macro. I get run-time error 75: Path/file access error message.

Any ideas on where I am going wrong? The code works fine if the folder doesn’t yet exist. I only get the error message if I am trying to show an existing folder. If I insert On Error Resume Next it doesn't do anything, but doesn't flash the run-time error.

Thanks in advance for any help you can give me.