Run Time Error 91 when linking contact to task in VBA

Status
Not open for further replies.

Patrece May

Member
Outlook version
Outlook 2010 32 bit
Email Account
Office 365 Exchange
I have a piece of code that creates a task then links a specified contact to the task. It worked fine in Outlook 2010, however I have recently updated to the most current version of Outlook (Office 365 version 1708) and the Links.Add method is now throwing the run time error 91 with the "object variable or with block variable not set" message. So, I pulled some code directly from the Microsoft Dev Ctr website and tried it, same error. The simplified code from the Microsoft website is listed below. Any assistance is very much appreciated.

Code:
Public Sub AddLink()
Dim myNameSpace As Outlook.NameSpace
Dim myFolder As Outlook.Folder
Dim myTask As Outlook.TaskItem
Dim myContact As Outlook.ContactItem
Dim myItems As Outlook.Items
Dim tempstr As String
Set myTask = Application.CreateItem(olTaskItem)
Set myNameSpace = Application.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderContacts)
tempstr = InputBox("Enter the name of the contact to link to this task")
If tempstr <> "" Then
tempstr = "[Full Name] = """ & tempstr & """"
Set myItems = myFolder.Items.Restrict("[MessageClass] = 'IPM.Contact.PPC'")
Set myContact = myItems.Find(tempstr)
myTask.Links.Add myContact '<<<--- this line throws error 91
myTask.Display
End If
End Sub
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
A Run-time error '430' on certain emails when trying to set "Outlook.mailitem" as "ActiveExplorer.Selection.Item" Outlook VBA and Custom Forms 2
A Run time error 424. object required in outlook 2013 Outlook VBA and Custom Forms 10
S VBA Macro - Run-time error '424': object required - Help Please Outlook VBA and Custom Forms 3
Vijay Error in rule- Run a script Using Outlook 1
J Run time error when using unbound fields in form Using Outlook 1
G OUTLOOK 2007 UNABLE TO RECEIVE EMAILS CAN'T RUN INBOX REPAIR TOOL AND ERROR (OX8E0CCC18) Using Outlook 2
F OLAddin run-time error '75": path/file access error Using Outlook 1
S outlook error 0x80070021 a prosses has outlook files open and backup cannot run Using Outlook 2
H Office OUtlook 2007 gives error message that says to run scanpst.exe and this is not found on my com Using Outlook 3
A "An OLE registration error Occurred. The Program is not correctly installed. Run Setup again for the Using Outlook 3
D Outlook report the error - "Cannot display the folder. There is not enough free memory to run this p Using Outlook 34
A vb6 run time error 5 when Outlook 2007 Explorer object displayed Outlook VBA and Custom Forms 1
L An OLE registration error occurred. The program is not correctly installed. Run Setup again for the Using Outlook 15
S Outlook Custom Form Scripting only working when clicking on "Run this form" Outlook VBA and Custom Forms 2
Y Outlook 2013 Run A Script Outlook VBA and Custom Forms 4
O Outlook 2016 This rule will only run when you check your email in Outlook.... Using Outlook 4
B run scripts Using Outlook 1
Dave A Run macro on existing appointment when it changes Outlook VBA and Custom Forms 1
O Run macro automatically at sending an email Using Outlook 11
P errors appear every time I run SCANPST Using Outlook 3
B Outlook rule run a Script doesn't work Outlook VBA and Custom Forms 1
B Wanting to run a script that will filter any body that has a russian link in it. Outlook VBA and Custom Forms 5
O Having rules run on old mails noved to inbox Outlook VBA and Custom Forms 8
Bri the Tech Guy Registry Tweak to make "Run a Script" Action Available Outlook VBA and Custom Forms 2
Bri the Tech Guy Run Script rule not running for newly arriving messages Outlook VBA and Custom Forms 25
J Custom form code doesn't run Outlook VBA and Custom Forms 2
J VBA Run When Reply Outlook VBA and Custom Forms 4
Vijay Run script doesn't work in outlook Using Outlook 1
O VBA to Run Font Change on Outlook Startup Outlook VBA and Custom Forms 4
D Creating an outlook session from Access vba but run silently. With A specific profile Outlook VBA and Custom Forms 1
Diane Poremsky Run a Script Rule: Send a New Message when a Message Arrives New Slipstick.com Articles 2
Diane Poremsky Using Scanpst in Outlook Click to Run New Slipstick.com Articles 0
oliv- How to Run a Script IN AN ADDIN with Outlook's Rules and Alerts Outlook VBA and Custom Forms 2
L Run a Script Rule doesn't work Using Outlook 5
B Can't run macro from QAT when emailing from Acrobat Outlook VBA and Custom Forms 0
J Outlook 2010 VBScript editor does not run code at all Outlook VBA and Custom Forms 0
X Outlook script to run excel data Outlook VBA and Custom Forms 1
D How to Run a Report Based on Age of Inbox Items Outlook VBA and Custom Forms 0
D RUN SCRIPT WHEN OUTLOOK IS CLOSE Outlook VBA and Custom Forms 1
L Cannot run script from rule Outlook VBA and Custom Forms 7
M Office 365 Click to run BCM (Business Contact Manager) 0
O modify vba to run it as script rule Outlook VBA and Custom Forms 8
D Must now "View on Facebook" for Mentions/Comments-Outlook 2013 click-to-run Using Outlook 2
P How many subs can run in one outlook VBA script Using Outlook 5
R Outlook won't run except in Safe mode problem Using Outlook 5
K Revert AutoArchive settings via GPO (Run Autoarchive every...) Using Outlook 4
Xueying run a script in rules, first time succeed, failed afterwards Outlook VBA and Custom Forms 3
G Outlook 2003 VBA Won't Run In Outlook 2010 Outlook VBA and Custom Forms 4
J Run Rules Now Using Outlook 1
Gary Brown Outlook 2013 VBA to run a rule Outlook VBA and Custom Forms 13
Similar threads


















































Top