What I want to do is use a CommandButton to make it so that when a user clicks on the button (which is in Excel2000), an e-mail message in Outlook 2000 is created that contains data from the Excel spreadsheet and also the Path of the Excel workbook. Below is what I have been using per Microsoft's KnowledgeBase (http://msdn.microsoft.com/library/officedev/off2000/olconWorkingWithFormsInVisualBasicEditor.htm
), but it doesn't seem to work correctly, any suggestions?
This code is within Sheet1
Private Sub CommandButton1_Click()
Dim myMail As Outlook.MailItem
Set myMail = Application.CreateItem(olM
.To = "email@example.com"
.Subject = "Subject"
.Body = "This cell contains: " & Sheet1.Range("G18").Value & "The path to the workbook is: " & ActiveSheet.PageSetup.Cent
erFooter = ThisWorkbook.FullName
I seem to get an error at the point that says "myMail As Outlook.MailItem" and I'm wondering if this is an incorrect Object name or something. Maybe I need to declare this as the Compile error message that I get is "User-defined type not defined".
I appreciate any insight that anyone may provide.