G
Guest
Hi,
I add a control button to a workbook commandBar. I use this button to send
this workbook as an atachment to a recipient. The problems are that for add a
workbook as an attachment I think that I have to save it before to the hard
disc.
So, when I use the "SaveAs" method, The user get a dialog box which I want
to prevent.The dialog says that the file is exist and ask for replace it. I
tried to use "ConflictResolution:=xlLocalSessionChanges" to prevent this
dialog but it dosn't help.
The second problem is when I send the workbook as an atachment I get this
dialog box : " A program try to send a mail automatically with your name. Do
you want to send it ?..it can be a virus.. " .How can I prevent this dialog
too.
Here the code:
ThisWorkbook.SaveAs Filename:="C:\Program
Files\MyOutlookAddIn\SelectedVisits.xls",
ConflictResolution:=xlLocalSessionChanges
Set myOlApp = CreateObject("Outlook.Application")
Set newItem = myOlApp.CreateItem(olMailItem)
newItem.Attachments.Add "C:\Program
Files\MyOutlookAddIn\SelectedVisits.xls"
newItem.Subject = "Visitors"
newItem.To = "(e-mail address removed)"
newItem.Send
Thanks
David
I add a control button to a workbook commandBar. I use this button to send
this workbook as an atachment to a recipient. The problems are that for add a
workbook as an attachment I think that I have to save it before to the hard
disc.
So, when I use the "SaveAs" method, The user get a dialog box which I want
to prevent.The dialog says that the file is exist and ask for replace it. I
tried to use "ConflictResolution:=xlLocalSessionChanges" to prevent this
dialog but it dosn't help.
The second problem is when I send the workbook as an atachment I get this
dialog box : " A program try to send a mail automatically with your name. Do
you want to send it ?..it can be a virus.. " .How can I prevent this dialog
too.
Here the code:
ThisWorkbook.SaveAs Filename:="C:\Program
Files\MyOutlookAddIn\SelectedVisits.xls",
ConflictResolution:=xlLocalSessionChanges
Set myOlApp = CreateObject("Outlook.Application")
Set newItem = myOlApp.CreateItem(olMailItem)
newItem.Attachments.Add "C:\Program
Files\MyOutlookAddIn\SelectedVisits.xls"
newItem.Subject = "Visitors"
newItem.To = "(e-mail address removed)"
newItem.Send
Thanks
David