Don't bother with writing a parser for file names -- that already exists in
Windows. Just include an On Error statement that will redirect the macro's
execution to an error handler if the name is invalid.
Dim MyFileName As String
MyFileName = "X:\bad path\possibly invalid filename.doc"
On Error GoTo BadFileName
Documents.Open(MyFileName)
' rest of the macro...
Exit Sub
BadFileName:
MsgBox MyFileName & " is not valid"
--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.