Complie erroe

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • thndrbd2
    New Member
    • May 2008
    • 2

    Complie erroe

    Hi all:

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

    Option Explicit
    Sub eMailActiveDocu ment()
    Dim OL As Object
    Dim EmailItem As Object
    Dim Doc As Document
    Application.Scr eenUpdating = False
    Application.Scr eenUpdating = False
    Set OL = CreateObject("O utlook.Applicat ion")
    Set EmailItem = OL.CreateItem(o lMailItem)
    Doc.Save
    With EmailItem
    .Subject = "AdHoc Request"
    .To = "thndrbd2@yahoo .com"
    '.Importance = olImportanceNor mal Or olImprotanceHig h Or olImprotanceLow
    .Attachments.Ad d Doc.Adhocreques t.Doc
    .Display
    ' .Send
    End With

    Application.Scr eenUpdating = 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(o lMailItem)

    Any ideas why?
  • Sick0Fant
    New Member
    • Feb 2008
    • 121

    #2
    Originally posted by thndrbd2
    Hi all:

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

    Option Explicit
    Sub eMailActiveDocu ment()
    Dim OL As Object
    Dim EmailItem As Object
    Dim Doc As Document
    Application.Scr eenUpdating = False
    Application.Scr eenUpdating = False
    Set OL = CreateObject("O utlook.Applicat ion")
    Set EmailItem = OL.CreateItem(o lMailItem)
    Doc.Save
    With EmailItem
    .Subject = "AdHoc Request"
    .To = "thndrbd2@yahoo .com"
    '.Importance = olImportanceNor mal Or olImprotanceHig h Or olImprotanceLow
    .Attachments.Ad d Doc.Adhocreques t.Doc
    .Display
    ' .Send
    End With

    Application.Scr eenUpdating = 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(o lMailItem)

    Any ideas why?
    If you posted the text of the error, it would help. Also, why use Late-binding?

    Comment

    Working...