Microsoft Office Tutorials and References
In Depth Information
Saving E-mail Attachments in a Specified Folder
ErrHandler:¶
Select Case Err.Number¶
Case 76 'Target directory doesn't exist¶
MsgBox "Selected directory doesn't exist.", _¶
vbOKOnly + vbExclamation, "Error"¶
Case Is <> 0 'Another critical error¶
MsgBox Err.Number & "-" & Err.Description, _¶
vbOKOnly + vbExclamation, "Error"¶
End Select¶
Resume ExitSub¶
End Sub¶
' * * * * *¶
Private Function SelectFolder() As String¶
SelectFolder = "C:\Temp"¶
'Alternative method might be using a user selected module¶
End Function¶
' * * * * *¶
Private Function ExplodeFileName(strFileName As String)¶
'Variable declaration¶
Dim dotPos As Integer¶
Dim strArr(1) As String¶
'Find the last dot position to parse strFileName¶
'InStrRev function is being used to start from the¶
'end of string¶
dotPos = InStrRev(strFileName, ".")¶
If dotPos = 0 Then¶
'There is no extension¶
strArr(0) = strFileName¶
strArr(1) = ""¶
Else¶
'Parse file name¶
strArr(0) = Left(strFileName, dotPos - 1)¶
'Parse file extension¶
strArr(1) = Right(strFileName, Len(strFileName) _¶
- dotPos + 1)¶
End If¶
'Return an array¶
'First item is the file name¶
'Second item is the file extension¶
ExplodeFileName = strArr¶
End Function¶
Out
Search JabSto ::




Custom Search