sg2209
12-15-2018, 07:54 AM
Hi Friends,
I was looking for the VBA Code when workbook gets saved and closed i will get the notification that it has updated, googled and found the below code.
pasted that in This Workbook however getting a Compile Error Expected :list separator or) on the 3rd line
"answer = MsgBox("Are You Sure You want to Save" vbYesNo,"Updated")"
Here is the code
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
Dim answer As String
answer = MsgBox("Are You Sure You want to Save" vbYesNo,"Updated")
If answer = vbNo Then Cancel = True
If answer = vbYes Then
'open outlook type stuff
Set OutlookApp = CreateObject("Outlook.Application")
Set OlObjects = OutlookApp.GetNamespace("MAPI")
Set newmsg = OutlookApp.CreateItem(olMailItem)
'add recipients
'newmsg.Recipients.Add ("Name Here")
newmsg.Recipients.Add ("sachin.gupta2209@live.com")
'add subject
newmsg.Subject = "Subject line of auto email here"
'add body
newmsg.Body = "body of auto email here"
newmsg.Display 'display
newmsg.Send 'send message
'give conformation of sent message
MsgBox "insert confirmation box test here", , "title of confirmation box"
End If
'save the document
'Me.Worksheets.Save
End Sub
Kindly help i don't know how to write the codes
I was looking for the VBA Code when workbook gets saved and closed i will get the notification that it has updated, googled and found the below code.
pasted that in This Workbook however getting a Compile Error Expected :list separator or) on the 3rd line
"answer = MsgBox("Are You Sure You want to Save" vbYesNo,"Updated")"
Here is the code
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
Dim answer As String
answer = MsgBox("Are You Sure You want to Save" vbYesNo,"Updated")
If answer = vbNo Then Cancel = True
If answer = vbYes Then
'open outlook type stuff
Set OutlookApp = CreateObject("Outlook.Application")
Set OlObjects = OutlookApp.GetNamespace("MAPI")
Set newmsg = OutlookApp.CreateItem(olMailItem)
'add recipients
'newmsg.Recipients.Add ("Name Here")
newmsg.Recipients.Add ("sachin.gupta2209@live.com")
'add subject
newmsg.Subject = "Subject line of auto email here"
'add body
newmsg.Body = "body of auto email here"
newmsg.Display 'display
newmsg.Send 'send message
'give conformation of sent message
MsgBox "insert confirmation box test here", , "title of confirmation box"
End If
'save the document
'Me.Worksheets.Save
End Sub
Kindly help i don't know how to write the codes