I’m using this code to run consecutive programs, which works really well, apart from one little glitch.
Public Sub main()
Call Sendmail
Call saveaspdfwithdate2
End Sub
The problem is that during the Sendmail sub if I select No on the vb, the program continues onto the next sub which unfortunately clears the data I have input to cells on the worksheet (as it should do).
I therefore need a piece of code which will end the main sub at this point, if No is selected, without running the saveaspdfwithdate2 coding.
Here is the coding for Sendmail
Sub Sendmail()
Dim objOutlook, objMsg, objNameSpace, opjFolder, strOutput, strSubject, StrTo, StrMsg
Dim ans
ans = MsgBox("Do you wish to save this System Register?", vbYesNo)
If ans = vbYes Then
'Continue
Else: Exit Sub
End If
StrTo = "joebloggs@123l.com"
StrMsg = InputBox("Name the Register ready for approval")
Const olMailItem = 0
Set objOutlook = CreateObject("Outlook.application")
Set objNameSpace = objOutlook.GetNameSpace("MAPI")
Set objMsg = objOutlook.CreateItem(olMailItem)
objMsg.To = StrTo
objMsg.Display
objMsg.Subject = "Register Added To Folder"
objMsg.Body = StrMsg
Set objFolder = Nothing
Set objNameSpace = Nothing
Set objOutlook = Nothing
Set ss = CreateObject("WScript.Shell")
Set ss = Nothing
End Sub
Bookmarks