By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,948 Members | 663 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,948 IT Pros & Developers. It's quick & easy.

Complie erroe

P: 2
Hi all:

I ahve written the following code within a word doc to and added menu item to execute the comands ...

Option Explicit
Sub eMailActiveDocument()
Dim OL As Object
Dim EmailItem As Object
Dim Doc As Document
Application.ScreenUpdating = False
Application.ScreenUpdating = False
Set OL = CreateObject("Outlook.Application")
Set EmailItem = OL.CreateItem(olMailItem)
Doc.Save
With EmailItem
.Subject = "AdHoc Request"
.To = "thndrbd2@yahoo.com"
'.Importance = olImportanceNormal Or olImprotanceHigh Or olImprotanceLow
.Attachments.Add Doc.Adhocrequest.Doc
.Display
' .Send
End With

Application.ScreenUpdating = True
Set Doc = Nothing
Set OL = Nothing
Set EmailItem = Nothing
End Sub

But when I run I receive a compile error referring to code:
Set EmailItem = OL.CreateItem(olMailItem)

Any ideas why?
May 22 '08 #1
Share this Question
Share on Google+
1 Reply


100+
P: 121
Hi all:

I ahve written the following code within a word doc to and added menu item to execute the comands ...

Option Explicit
Sub eMailActiveDocument()
Dim OL As Object
Dim EmailItem As Object
Dim Doc As Document
Application.ScreenUpdating = False
Application.ScreenUpdating = False
Set OL = CreateObject("Outlook.Application")
Set EmailItem = OL.CreateItem(olMailItem)
Doc.Save
With EmailItem
.Subject = "AdHoc Request"
.To = "thndrbd2@yahoo.com"
'.Importance = olImportanceNormal Or olImprotanceHigh Or olImprotanceLow
.Attachments.Add Doc.Adhocrequest.Doc
.Display
' .Send
End With

Application.ScreenUpdating = True
Set Doc = Nothing
Set OL = Nothing
Set EmailItem = Nothing
End Sub

But when I run I receive a compile error referring to code:
Set EmailItem = OL.CreateItem(olMailItem)

Any ideas why?
If you posted the text of the error, it would help. Also, why use Late-binding?
May 22 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.