Log in

View Full Version : [SOLVED:] "Function Call on left-hand side of assignment must return variant or object"



nathandavies
08-22-2017, 05:44 AM
Hi All, I have made a modification to some code, so that if I send an email it asks if i want to save the attachment or not in a different folder but i keep getting an error "Function Call on left-hand side of assignment must return variant or object"

Doe anyone have any ideas how to solve this issue?


If olItem.Sender Like "Nathan" Then 'INSERT NAME HERE
MsgBox("Save Attachments?", vbYesNo, "Save Attachments?") = vbYes
SaveAttachments olItem, strPath & "\Documents\Documents Sent\"
Else
SaveAttachments olItem, strPath & "\Documents\Documents Received\"

'If bExcel = True Then
'CopyToExcel olItem, strPath

End If
lbl_Exit:
Exit Sub
End Sub

Aflatoon
08-22-2017, 06:27 AM
What are you trying to do with that MsgBox statement? You can't assign a value to it other than by clicking a button on the message box. I guess you meant to use another If...Then block?

nathandavies
08-22-2017, 06:32 AM
If "yes" is selected then save then SaveAttachments olItem, strPath & "\Documents\Documents Sent\"
if "no" is selected then end sub.

SamT
08-22-2017, 06:39 AM
If MsgBox("Save Attachments?", vbYesNo, "Save Attachments?") = vbYes Then
SaveAttach..........
End If

nathandavies
08-22-2017, 06:42 AM
Thanks SamT, that has worked now!