I am not sure if there is an answer for that, although this looks like a REALLY simple question.
I am using a vba code to open a file in a Sharepoint, however, as I cannot use the Len(Dir()) to check if the file really exists, I used a code which I found in a forum but this code does not work the way I thought it would.
What I needed was a code to look for several files in the Sharepoint and each file need to have the current date (For example: If we are in July 2014, the file must be named as Name_July2014, not Name_June2014 or May_2014). Since the file with the current date might not exist, then it would be entered the message "Not Updated" in a specific cell in the workbook I am using and the macro would continue to run. The code works well, but it stops every time to show a message that the file does not exists. This message appears everytime the macro tries to open a file that does not exist. I needed to skip this warning and let the code run. I thought this code would skip the warning (using On Error GoTo) and this would be the way to show that a file exists, but it's not working. Can anyone take a look?
Can I avoid somehow the message "The internet address ... is not valid"?
Really sorry if I wasn't clear enough because of my English and sorry if this question has already been answered in another post.
This is what the code looks like:
'Open the file and checks if the name of the file opened is different from the
'previous file opened
On Error Resume Next
Application.Workbooks.Open (fileName)
newBook = ActiveWorkbook.Name
If originalBook = newBook Then
[the file does not exist, do something]
Else
[the file exists, do something else]
End If
On Error Goto