Please check code

A

albycindy

What is wrong with this code? I can see Outlook trying to do something in my
Start Bar but then nothing happens!!!!

Private Sub CommandButton1_Click()
Dim Document As Word.Document
Set Document = ActiveDocument
Dim Olk As Outlook.Application
Set Olk = CreateObject("Outlook.Application")
Dim OlkMsg As Outlook.MailItem
Set OlkMsg = Olk.CreateItem(olMailItem)
With OlkMsg
.To = "Cindy Van Dongen"
.Subject = "Request for Claim"
.Body = "Change this text!"
.Attachments = ActiveDocument
End With
End Sub
 
A

albycindy

Ignore the first two lines of code, just trying out something else.

This is the code part to check..

Private Sub CommandButton1_Click()
Dim Olk As Outlook.Application
Set Olk = CreateObject("Outlook.Application")
Dim OlkMsg As Outlook.MailItem
Set OlkMsg = Olk.CreateItem(olMailItem)
With OlkMsg
.To = "Cindy Van Dongen"
.Subject = "Request for Claim"
.Body = "Cindy,Change this text!"
.Attachments = ActiveDocument
End With
End Sub

Thanks.
 
J

Jezebel

Not sure of the details of what you're trying to do, but this line can't
work:

.Attachments = ActiveDocument

ActiveDocument is an object, so you need to SET any assignment of it.
 
A

albycindy

Anything like this?

Private Sub CommandButton2_Click()
Dim Lynx As Word.Document
Set Lynx = ActiveDocument
Dim Olk As Outlook.Application
Set Olk = CreateObject("Outlook.Application")
Dim OlkMsg As Outlook.MailItem
Set OlkMsg = CreateItem(olMailItem)
With OlkMsg
.To = "Cindy Van Dongen"
.CC = "Jackie Fletcher"
.Body = "Request for Claim"
.Attachments = Lynx
End With
End Sub
 
H

Helmut Weber

Hi,
Not sure of the details of what you're trying to do,
but this line can't work:

.Attachments = ActiveDocument
That would be;
.attachments.Add ActiveDocument.FullName

The doc has to be saved at least once under a proper,
name, otherwise FullName returns nothing.

Maybe something else is wrong, too.

Google will find you many examples.

Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
 
A

albycindy

To clarify...

I'm trying to get a button in a Word document from template to send the
active document from template as an email attachment to one person and CC to
another. (Always the same ppl).

Am copying most of it from Dummies book to be truthful!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top