View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Conditional Sheet Attachment

That isn't how you would leave the to address blank. You would need to at
least remove/comment out the lines

Set objOneRecip = objMessage.Recipients.Add
objOneRecip.Name = "
objOneRecip.Type = 1
objOneRecip.Resolve

--
Regards,
Tom Ogilvy



Todd uttenstine wrote in message
...
No when I remove
the " out of that
line and only put "".


-----Original Message-----
Do you mean when you remove these lines of code

Set objOneRecip = objMessage.Recipients.Add
objOneRecip.Name = "
objOneRecip.Type = 1
objOneRecip.Resolve
objMessage.Send showDialog:=True
objSession.Logoff

You get an error?

--
Regards,
Tom Ogilvy


Todd Huttenstine

wrote in message
...
Combobox1 is populated with sheet names. The user will
select a sheetname from the combobox.

What is the code that will attach the sheet that is in
combobox1 and bring up an outlook email dialog box. I
want the email dialog box to have the subject of "Stats"
and an empty body and To address field.

For example, the user clicks the combobox and selects

the
value "Todd Huttenstine". When the code is run, it must
attach worksheet "Todd Huttenstine" to the email.

Below is the code I have so far, but I want my email
address taken out. When I take it out I get an error.

Can anyone please show me the modified code to perform

the
task?



Option Explicit
Private Sub CommandButton1_Click()
Dim objSession As Object, objMessage As Object,
objOneRecip As Object
Set objSession = CreateObject("MAPI.Session")
objSession.Logon
Set objMessage = objSession.Outbox.Messages.Add
objMessage.Subject = "Stats"
objMessage.Text = ""
Set objOneRecip = objMessage.Recipients.Add
objOneRecip.Name

= "
objOneRecip.Type = 1
objOneRecip.Resolve
objMessage.Send showDialog:=True
objSession.Logoff


End Sub

Thank you

Todd Huttenstine



.