Home Invalid attribute in sub or function - Outlook VBA
Reply: 0

Invalid attribute in sub or function - Outlook VBA

Ashish Baboo
1#
Ashish Baboo Published in 2017-12-07 13:17:44Z

I have written a macro which runs as soon as a new mail is received. But i am receiving an error that "invalid attribute in sub or function". It gives error in first line itself.how can i resolve this? following is my code:

Private WithEvents Items1 As Outlook.Items
Private Sub tracker()
  Dim olApp1 As Outlook.Application
  Dim objNS1 As Outlook.NameSpace
  Set olApp1 = Outlook.Application
  Set objNS1 = olApp.GetNamespace("MAPI")
  ' default local Inbox
  Set Items1 = objNS.Session.Folders("ashish.baboo@xmmail.com").Items
End Sub
Private Sub tracker_ItemAdd(ByVal item1 As Object)

  'On Error GoTo ErrorHandler
  Dim Msg1 As Outlook.MailItem
  Dim oMsg1 As Outlook.MailItem
  Dim track As Excel.Workbook
If TypeName(item) = "MailItem" Then
    Set Msg = item
    a = Replace(Msg.Subject, "'", "")
    b = Msg.Body

    name = Trim(Replace(a, "INSIRT Analysis - ", ""))
    name1 = Trim(Replace(a, "INSIRT Analysis:", ""))
    If InStr(b, "STATUS") Then
        If InStr(b, "LIMIT") Then
            If name <> "" Then
                Set track = Workbooks.Open("Z:\Personal Folder\Ashish Baboo\UKT - Tracker.xlsx")
                LR = track.Sheets("Quote").Range("B" & track.Sheets("Quote").Rows.Count).End(-4162).Row
                track.Sheets("Quote").Range("B" & LR) = name
            ElseIf name1 <> "" Then
                Set track = Workbooks.Open("Z:\Personal Folder\Ashish Baboo\UKT - Tracker.xlsx")
                LR = track.Sheets("Quote").Range("B" & track.Sheets("Quote").Rows.Count).End(-4162).Row
                MsgBox LR
                track.Sheets("Quote").Range("B" & LR) = name1
            End If
            If track.Saved = False Then
        track.Save
    End If
    track.Close
        End If
    End If
End Sub
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.30358 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO