How to Save Outlook Message useing `OpenFileDialog` to select a folder - vba

I am using the below Code to Save email in specific folder.
By Default it should save in Specific folder however sometimes if i want to save in other folders I need to type the location manually.
How do I use OpenFileDialog to select a folder.
Option Explicit
Sub SaveMessage()
Dim olMsg As MailItem
On Error Resume Next
Set olMsg = ActiveExplorer.Selection.Item(1)
If Not TypeName(olMsg) = "MailItem" Then
MsgBox "Select a mail item!"
GoTo lbl_Exit
End If
SaveItem olMsg
lbl_Exit:
Set olMsg = Nothing
Exit Sub
End Sub
Sub SaveItem(olItem As MailItem)
Dim fname As String
Dim fPath As String
Dim JVvalue As Variant
fPath = "C:\GUIC\JV Approval Backup"
CreateFolders fPath
If olItem.Sender Like "*#gmayor.com" & olItem.Subject Like "*RE" Then 'Your domain
fname = JVvalue & " " & Chr(32) & olItem.SenderName & " " & Format(olItem.SentOn, "mmmm" & " " & "YYYY-MM-DD") & Chr(32) & _
Format(olItem.SentOn, "HH.MM") & " " & " " & Chr(32) & olItem.Subject
Else
fname = JVvalue & " " & Chr(32) & olItem.SenderName & " " & Format(olItem.ReceivedTime, "mmmm" & " " & "YYYY-MM-DD") & Chr(32) & _
Format(olItem.ReceivedTime, "HH.MM") & " " & " " & Chr(32) & olItem.Subject
End If
fname = Replace(fname, Chr(58) & Chr(41), "")
fname = Replace(fname, Chr(58) & Chr(40), "")
fname = Replace(fname, Chr(34), "-")
fname = Replace(fname, Chr(42), "-")
fname = Replace(fname, Chr(47), "-")
fname = Replace(fname, Chr(58), "-")
fname = Replace(fname, Chr(60), "-")
fname = Replace(fname, Chr(62), "-")
fname = Replace(fname, Chr(63), "-")
fname = Replace(fname, Chr(124), "-")
SaveUnique olItem, fPath, fname
lbl_Exit:
Exit Sub
End Sub**
Private Function CreateFolders(strPath As String)
Dim strTempPath As String
Dim lngPath As Long
Dim vPath As Variant
vPath = Split(strPath, "\")
strPath = vPath(0) & "\"
For lngPath = 1 To UBound(vPath)
strPath = strPath & vPath(lngPath) & "\"
If Not FolderExists(strPath) Then MkDir strPath
Next lngPath
lbl_Exit:
Exit Function
End Function
Private Function SaveUnique(oItem As Object, _
strPath As String, _
strFileName As String)
Dim lngF As Long
Dim lngName As Long
lngF = 1
lngName = Len(strFileName)
Do While FileExists(strPath & strFileName & ".msg") = True
strFileName = Left(strFileName, lngName) & "(" & lngF & ")"
lngF = lngF + 1
Loop
oItem.SaveAs strPath & strFileName & ".msg"
lbl_Exit:
Exit Function
End Function
Private Function FileExists(filespec As String) As Boolean
'An Office macro by Graham Mayor - www.gmayor.com
Dim FSO As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
If FSO.FileExists(filespec) Then
FileExists = True
Else
FileExists = False
End If
lbl_Exit:
Exit Function
End Function
Private Function FolderExists(fldr As String) As Boolean
Dim FSO As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
If (FSO.FolderExists(fldr)) Then
FolderExists = True
Else
FolderExists = False
End If
lbl_Exit:
Exit Function
End Function

Work with Shell.Application MSDN to browse for local folder
Try the following Example
Option Explicit
Dim fPath As String
Sub SaveMessage()
Dim olMsg As MailItem
On Error Resume Next
Set olMsg = ActiveExplorer.Selection.Item(1)
If Not TypeName(olMsg) = "MailItem" Then
MsgBox "Select a mail item!"
GoTo lbl_Exit
End If
SaveItem olMsg
lbl_Exit:
Set olMsg = Nothing
Exit Sub
End Sub
Sub SaveItem(olItem As MailItem)
Dim fname As String
Dim JVvalue As Variant
Dim Result As Integer
Result = MsgBox("Save it to default folder?", vbQuestion + vbYesNo)
If Result = vbYes Then
fPath = "C:\GUIC\JV Approval Backup"
CreateFolders fPath
Else
BrowseForFolder fPath
End If
If olItem.Sender Like "*gmayor.com" & olItem.Subject Like "*RE" Then
fname = JVvalue & " " & Chr(32) & _
olItem.SenderName & " " & _
Format(olItem.SentOn, "mmmm" & " " _
& "YYYY-MM-DD") & Chr(32) & _
Format(olItem.SentOn, "HH.MM") & " " & _
" " & Chr(32) & olItem.Subject
Else
fname = JVvalue & " " & Chr(32) & olItem.SenderName & _
" " & Format(olItem.ReceivedTime, "mmmm" & _
" " & "YYYY-MM-DD") & Chr(32) & _
Format(olItem.ReceivedTime, "HH.MM") & " " & _
" " & Chr(32) & olItem.Subject
End If
fname = Replace(fname, Chr(58) & Chr(41), "")
fname = Replace(fname, Chr(58) & Chr(40), "")
fname = Replace(fname, Chr(34), "-")
fname = Replace(fname, Chr(42), "-")
fname = Replace(fname, Chr(47), "-")
fname = Replace(fname, Chr(58), "-")
fname = Replace(fname, Chr(60), "-")
fname = Replace(fname, Chr(62), "-")
fname = Replace(fname, Chr(63), "-")
fname = Replace(fname, Chr(124), "-")
SaveUnique olItem, fPath, fname
lbl_Exit:
Exit Sub
End Sub
Private Function CreateFolders(strPath As String)
Dim strTempPath As String
Dim lngPath As Long
Dim vPath As Variant
vPath = Split(strPath, "\")
strPath = vPath(0) & "\"
For lngPath = 1 To UBound(vPath)
strPath = strPath & vPath(lngPath) & "\"
If Not FolderExists(strPath) Then MkDir strPath
Next lngPath
lbl_Exit:
Exit Function
End Function
Private Function SaveUnique(oItem As Object, _
strPath As String, _
strFileName As String)
Dim lngF As Long
Dim lngName As Long
lngF = 1
lngName = Len(strFileName)
Do While FileExists(strPath & strFileName & ".msg") = True
strFileName = Left(strFileName, lngName) & "(" & lngF & ")"
lngF = lngF + 1
Loop
oItem.SaveAs strPath & strFileName & ".msg"
Debug.Print strPath & strFileName & ".msg"
lbl_Exit:
Exit Function
End Function
Private Function FileExists(filespec As String) As Boolean
'An Office macro by Graham Mayor - www.gmayor.com
Dim FSO As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
If FSO.FileExists(filespec) Then
FileExists = True
Else
FileExists = False
End If
lbl_Exit:
Exit Function
End Function
Private Function FolderExists(fldr As String) As Boolean
Dim FSO As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
If (FSO.FolderExists(fldr)) Then
FolderExists = True
Else
FolderExists = False
End If
lbl_Exit:
Exit Function
End Function
Function BrowseForFolder(fPath As String, _
Optional OpenAt As String) As String
Dim objShell As Object
Dim objFolder ' As Folder
Dim enviro
enviro = CStr(Environ("USERPROFILE"))
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder(0, "Please choose a folder", _
0, enviro & "C:\Temp\Folders")
fPath = objFolder.self.Path
fPath = fPath & "\"
Debug.Print fPath
On Error Resume Next
On Error GoTo 0
ExitFunction:
Set objShell = Nothing
End Function

Related

VBA Macro to report links on powerpoint slides

I am trying to modify some code to retrieve any links in powerpoint slides and print them to a document. I am struggling to get the objects.
Here is what I have already:
Sub LinkCounter()
Dim FileNum As Integer
Dim oFile As String
Dim textLink() As Shape, i As Long
FileNum = FreeFile()
oFile = ActivePresentation.Path & "\LinksReport.txt"
If Dir(oFile, vbNormal) <> vbNullString Then
Kill oFile
End If
i = 0
p = 1
Open oFile For Append As #FileNum
Print #FileNum, "Links counted on slides"
For Each Slide In ActivePresentation.Slides
Print #FileNum, "Slide"; p
p = p + 1
For Each Hyperlinks.Address In Slide.Hyperlinks
Set textLink(i) = Hyperlinks.Address
Print #FileNum, textLink(i)
i = i + 1
Next Hyperlinks.Address
Next Slide
Close FileNum
End Sub
Any help would be appreciated!
After some deeper searching I found a piece of code that achieves this, it would be good to know where I went wrong however, I'm guessing I need to loop through shapes to find the links?
Sub PPHyperlinkReport()
Dim oSl As Slide
Dim oHl As Hyperlink
Dim sReport As String
Dim iFileNum As Integer
Dim sFileName As String
For Each oSl In ActivePresentation.Slides
For Each oHl In oSl.Hyperlinks
If oHl.Type = msoHyperlinkShape Then
If oHl.Address <> "" Then
sReport = sReport & "HYPERLINK IN SHAPE" _
& vbCrLf _
& "Slide: " & vbTab & oSl.SlideIndex _
& vbCrLf _
& "Shape: " & vbTab & oHl.Parent.Parent.Name _
& vbCrLf _
& "Text: """ & oHl.Parent.Parent.TextFrame.TextRange.Text & """" _
& vbCrLf _
& "External link address:" & vbTab & oHl.Address & vbCrLf & vbNewLine & vbNewLine
Else
sReport = sReport & ""
End If
Else
If oHl.Address <> "" Then
sReport = sReport & "HYPERLINK IN TEXT" _
& vbCrLf _
& "Slide: " & vbTab & oSl.SlideIndex _
& vbCrLf _
& "Shape: " & vbTab & oHl.Parent.Parent.Parent.Parent.Name _
& vbCrLf _
& "Text: """ & oHl.Parent.Parent.Text & """" _
& vbCrLf _
& "External link address:" & vbTab & oHl.Address & vbCrLf & vbNewLine & vbNewLine
Else
sReport = sReport & ""
End If
End If
Next ' hyperlink
Next ' Slide
iFileNum = FreeFile()
sFileName = ActivePresentation.Path & "\AuthorTec_Edits.txt"
Open sFileName For Output As iFileNum
Print #iFileNum, sReport
Close #iFileNum
Call Shell("NOTEPAD.EXE " & sFileName, vbNormalFocus)
End Sub

Access Database VB

I have a database built in access
I need to create a button where I click it and it will open a folder related to Employee ID
the problem is that the employee's folders are named as John Mich 000321 where the 000321 is john Employee Id
Try below sub
Private Sub cmdOpenEmpFolder_Click()
Dim partialName As String, partialFolder As String
Dim folderName As String
Dim folderfullPath As String
partialName = CStr(Me.txtEmployeeID)
partialFolder = Application.CurrentProject.Path & "\"
folderName = Dir(partialFolder & "*" & partialName, vbDirectory)
folderfullPath = partialFolder & folderName
Debug.Print "explorer.exe " & Chr(34) & folderfullPath & Chr(34)
Shell "explorer.exe " & Chr(34) & folderfullPath & Chr(34), vbNormalFocus
End Sub

Renaming folders using VBA

I am trying to rename folders based upon a template that a user will fill out. The user will specify the old name of the folder and what it will be updated to. There are bunch of sub folders that also get the name change.
I have confirmed that the folders exist and in the locations that they should be so I don't understand why this is failing. I have also tried using FileSystem objects and get the same problem.
Any help would be greatly appreciated.
Sub UpdateMain()
'string capture variables
Dim currentLocation As String
Dim currentName As String
Dim customerNumber As String
Dim newName As String
'path creation variables
Dim rootPath As String
Dim currentPath As String
Dim newPath As String
'counter variables
Dim i As Integer
With wsUpdate
currentLocation = .Range("B1")
currentName = .Range("B2")
customerNumber = .Range("B3")
newName = .Range("B5")
End With
'create path and folder for the root folder
rootPath = currentLocation & "\" & currentName & " (" & customerNumber & ")"
'edit all subfolders prior to root folder
i = 0
With wsUpdate.Range("A8")
Do Until .Offset(i, 0) = ""
If .Offset(i, 1) = "Customer" Then
currentPath = rootPath & "\" & currentName & " " & .Offset(i, 0)
newPath = rootPath & "\" & newName & " " & .Offset(i, 0)
Else
currentPath = rootPath & "\" & currentName & " " & .Offset(i, 1) & "\" & currentName & " " & .Offset(i, 0)
newPath = rootPath & "\" & newName & " " & .Offset(i, 1) & "\" & newName & " " & .Offset(i, 0)
End If
Call FolderNameEdit(currentPath, newPath)
i = i + 1
Loop
End With
'edit root folder
currentPath = currentLocation & "\" & currentName & " (" & customerNumber & ")"
newPath = currentLocation & "\" & newName & " (" & customerNumber & ")"
Call FolderNameEdit(currentPath, newPath)
End Sub
Sub FolderNameEdit(currentPath As String, newPath As String)
Name currentPath As newPath
End Sub
I keep getting
Run-time error '53': File not found.
The error occurs on line:
Name currentPath as newPath
Check folders before renaming:
Sub FolderNameEdit(currentPath As String, newPath As String)
If Dir(currentPath, vbDirectory) = vbNullString Then
' error
ElseIf Dir(newPath, vbDirectory) <> vbNullString Then
' error
Else
Name currentPath As newPath
End If
End Sub

Save emails to pdf without notification

I have found this code to download emails and convert them to PDF. It works perfectly but the only question that I have is it possible to remove the save notification and that it saves it automaticly when you trigger the macro?
Below is whole my code:
Set objAttachments = Nothing
Set objMsg = Nothing
Set objSelection = Nothing
Set objOL = Nothing
Set MyOlNamespace = Application.GetNamespace("MAPI")
Set MySelectedItem = ActiveExplorer.Selection.Item(1)
Set fso = CreateObject("Scripting.FileSystemObject")
'tmpFileName = FSO.GetSpecialFolder(2)
tmpFileName = "C:\CRM\Postboek\Ongekoppeld"
strRecieved = MySelectedItem.ReceivedByName
strSender = MySelectedItem.SenderName
strDatum = MySelectedItem.ReceivedTime
strDatum = Replace(strDatum, ":", "-")
strDatum = Replace(strDatum, "/", "-")
strName = "email_temp.mht"
tmpFileName = tmpFileName & "\" & strName
MySelectedItem.SaveAs tmpFileName, 10
On Error Resume Next
' If MySelectedItem.BodyFormat <> olFormatHTML Then
' strDeletedFiles = strDeletedFiles & vbCrLf & "<file://" & strFile & ">"
' Else
' strDeletedFiles = strDeletedFiles & "<br>" & "<a href='file://" & _
'' strFile & "'>" & strFile & "</a>"
' End If
' If MySelectedItem.BodyFormat <> olFormatHTML Then
' MySelectedItem.Body = vbCrLf & "The file(s) were saved to " & strDeletedFiles & vbCrLf & MySelectedItem.Body
' Else
' MySelectedItem.HTMLBody = "<p>" & "The file(s) were saved to " & strDeletedFiles & "</p>" & MySelectedItem.HTMLBody
' End If
Set wrdApp = GetObject(, "Word.Application")
If Err Then
Set wrdApp = CreateObject("Word.Application")
bStarted = True
End If
On Error GoTo 0
Set wrdDoc = wrdApp.Documents.Open(FileName:=tmpFileName, Visible:=False, Format:=7)
Set dlgSaveAs = wrdApp.FileDialog(msoFileDialogSaveAs)
Set fdfs = dlgSaveAs.Filters
i = 0
For Each fdf In fdfs
i = i + 1
If InStr(1, fdf.Extensions, "pdf", vbTextCompare) > 0 Then
Exit For
End If
Next fdf
dlgSaveAs.FilterIndex = i
Set WshShell = CreateObject("WScript.Shell")
'SpecialPath = WshShell.SpecialFolders(16)
SpecialPath = "C:\CRM\Postboek\Ongekoppeld"
msgFileName = MySelectedItem.Subject
msgFileName = Replace(msgFileName, ":", "-")
Set oRegEx = CreateObject("vbscript.regexp")
oRegEx.Global = True
oRegEx.Pattern = "[\/:*?""<>|]"
'msgFileName = Trim(oRegEx.Replace(msgFileName, ""))
'msgFileName = Trim(oRegEx.Replace(msgFileName, ""))
If Len(strRecieved) = 0 Then
dlgSaveAs.InitialFileName = SpecialPath & "\" & msgFileName & " - " & strSender & " - " & strDatum
ElseIf Len(strRecieved) > 0 Then
dlgSaveAs.InitialFileName = SpecialPath & "\" & msgFileName & " - " & strRecieved & " - " & strDatum
End If
'dlgSaveAs.InitialFileName = SpecialPath & "\" & msgFileName & " - " & strRecieved & " - " & strDatum
If dlgSaveAs.Show = -1 Then
strCurrentFile = dlgSaveAs.SelectedItems(1)
If Right(strCurrentFile, 4) <> ".pdf" Then
Response = MsgBox("Sorry, only saving in the pdf-format is supported." & _
vbNewLine & vbNewLine & "Save as pdf instead?", vbInformation + vbOKCancel)
If Response = vbCancel Then
wrdDoc.Close 0
If bStarted Then wrdApp.Quit
Exit Sub
ElseIf Response = vbOK Then
intPos = InStrRev(strCurrentFile, ".")
If intPos > 0 Then
strCurrentFile = Left(strCurrentFile, intPos - 1)
End If
strCurrentFile = strCurrentFile & ".pdf"
End If
End If
wrdApp.ActiveDocument.ExportAsFixedFormat OutputFileName:= _
strCurrentFile, _
ExportFormat:=17, _
OpenAfterExport:=False, _
OptimizeFor:=0, _
Range:=0, _
From:=0, _
To:=0, _
Item:=0, _
IncludeDocProps:=True, _
KeepIRM:=True, _
CreateBookmarks:=0, _
DocStructureTags:=True, _
BitmapMissingFonts:=True, _
UseISO19005_1:=False
End If
Set dlgSaveAs = Nothing
wrdDoc.Close
If bStarted Then wrdApp.Quit
Set MyOlNamespace = Nothing
Set MySelectedItem = Nothing
Set wrdDoc = Nothing
Set wrdApp = Nothing
Set oRegEx = Nothing
End Sub
This part gives the notification to the user if they want to save it and I actually just want it removed:
If dlgSaveAs.Show = -1 Then
strCurrentFile = dlgSaveAs.SelectedItems(1)
If Right(strCurrentFile, 4) <> ".pdf" Then
Response = MsgBox("Sorry, only saving in the pdf-format is supported." & _
vbNewLine & vbNewLine & "Save as pdf instead?", vbInformation + vbOKCancel)
If Response = vbCancel Then
wrdDoc.Close 0
If bStarted Then wrdApp.Quit
Exit Sub
ElseIf Response = vbOK Then
intPos = InStrRev(strCurrentFile, ".")
If intPos > 0 Then
strCurrentFile = Left(strCurrentFile, intPos - 1)
End If
strCurrentFile = strCurrentFile & ".pdf"
End If
End If
Here is a screenshot of what I want to be removed:
screenshot
Remove this part:
If Len(strRecieved) = 0 Then
dlgSaveAs.InitialFileName = SpecialPath & "\" & msgFileName & " - " & strSender & " - " & strDatum
ElseIf Len(strRecieved) > 0 Then
dlgSaveAs.InitialFileName = SpecialPath & "\" & msgFileName & " - " & strRecieved & " - " & strDatum
End If
'dlgSaveAs.InitialFileName = SpecialPath & "\" & msgFileName & " - " & strRecieved & " - " & strDatum
If dlgSaveAs.Show = -1 Then
strCurrentFile = dlgSaveAs.SelectedItems(1)
If Right(strCurrentFile, 4) <> ".pdf" Then
Response = MsgBox("Sorry, only saving in the pdf-format is supported." & _
vbNewLine & vbNewLine & "Save as pdf instead?", vbInformation + vbOKCancel)
If Response = vbCancel Then
wrdDoc.Close 0
If bStarted Then wrdApp.Quit
Exit Sub
ElseIf Response = vbOK Then
intPos = InStrRev(strCurrentFile, ".")
If intPos > 0 Then
strCurrentFile = Left(strCurrentFile, intPos - 1)
End If
strCurrentFile = strCurrentFile & ".pdf"
End If
End If
Set the file name you want below:
wrdApp.ActiveDocument.ExportAsFixedFormat OutputFileName:= _
___PUTYOURFILENAMEHERE___, _
ExportFormat:=17, _
OpenAfterExport:=False, _
OptimizeFor:=0, _
Range:=0, _
From:=0, _
To:=0, _
Item:=0, _
IncludeDocProps:=True, _
KeepIRM:=True, _
CreateBookmarks:=0, _
DocStructureTags:=True, _
BitmapMissingFonts:=True, _
UseISO19005_1:=False

Search for Outlook Email based on Sender, Subject, and Today's Date

I am supposed to receive an email with the subject "Testing Protocol" from "BobSmith#company.com" every day.
Is there a way to search my Outlook Inbox to determine if an email has come through with that subject and that sender for the current day? Id like a simple "Yes" or "No" to be placed in cell A1 of "Control" if it has or has not been received today.
Below is what I have tried to come up with on my own using previous questions with no luck.
Any help is greatly appreciated. EmailSubject = "Testing Protocol"
Private Sub Application_Reminder(ByVal Item As Object)
Dim EmailSubject As Range
Set EmailSubject = Sheets("Control").Range("EmailSubject")
If Item.Class = olTask Then
If InStr(Item.Subject, EmailSubject) > 0 Then
ReminderUnreceivedMail
End If
End If
End Sub
Sub ReminderUnreceivedMail()
Dim Itms As Items
Dim srchSender As String
Dim srchSubject As String
Set Itms = GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Items
srchSender = "BobSmith#company.com"
srchSubject = EmailSubject
Set Itms = Itms.Restrict("[SenderName] = "BobSmith#company.com" And
[Subject] = EmailSubject And [SentOn] > '" & Format(Date, "yyyy-mm-dd") &
"'")
If Itms.Count = 0 Then
MsgBox "No " & srchSubject & " email on " & Format(Date, "yyyy-mm-dd")
End If
Set Itms = Nothing
End Sub
Likely wrong format for srchSender and combining a filter, for me, requires a confusing sequence of matching quotes.
Private Sub ReminderUnreceivedMail()
Dim Itms As items
Dim srchSender As String
Dim srchSubject As String
Dim strFilterBuild As String
Dim ItmsBuild As items
Dim strFilter As String
Set Itms = GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).items
Dim i As Long
For i = 1 To Itms.count
Debug.Print Itms(i).senderName
Next
srchSender = "what you see in senderName from the above"
srchSubject = "EmailSubject"
' If you cannot get the quotes right all at once, build the filter.
strFilterBuild = "[SenderName] = '" & srchSender & "'"
Debug.Print strFilterBuild
Set ItmsBuild = Itms.Restrict(strFilterBuild)
If ItmsBuild.count = 0 Then
MsgBox "No " & srchSender & " email."
GoTo ExitRoutine
End If
strFilterBuild = strFilterBuild & " And [Subject] = '" & srchSubject & "'"
Debug.Print strFilterBuild
Set ItmsBuild = Itms.Restrict(strFilterBuild)
If ItmsBuild.count = 0 Then
' This should find old mail
MsgBox "No " & srchSender & " email with subject " & srchSubject
GoTo ExitRoutine
End If
strFilterBuild = strFilterBuild & " And [SentOn] > '" & Format(Date, "yyyy-mm-dd") & "'"
Debug.Print strFilterBuild
Set ItmsBuild = Itms.Restrict(strFilterBuild)
If ItmsBuild.count = 0 Then
MsgBox "No " & srchSender & " email with subject " & srchSubject & " today"
GoTo ExitRoutine
End If
' This should match the final strFilterBuild to confirm it can be done all at once.
strFilter = "[SenderName] = '" & srchSender & "' And [Subject] = '" & srchSubject & "' And [SentOn] > '" & Format(Date, "yyyy-mm-dd") & "'"
Debug.Print strFilter
Set Itms = Itms.Restrict(strFilter)
If Itms.count = 0 Then
MsgBox "No " & srchSubject & " email on " & Format(Date, "yyyy-mm-dd")
End If
ExitRoutine:
Set Itms = Nothing
End Sub