VB script in outlook form doesn't work anymore

Status
Not open for further replies.
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
I used the following script for years in a customized outlook form to populate a combo box with outlook contacts. This worked fine until a couple of months ago. Now it doesn't work anymore.

Sub Item_Open()

Dim FullArray()

' Sets the name of page on the form (Termindetails)
Set FormPage = Item.GetInspector.ModifiedFormPages("Termindetails")

' Sets Control to a list box called ComboBox1.
Set Control = FormPage.Controls("ComboBox1")

' Get the default Contacts folder
Set ConFolder = Application.Session.GetDefaultFolder(10)

' Get the items in the folder
Set ConItems = ConFolder.Items

' Create a restrict filter
strFilter = "[Journal] = 1 "

' Just get those contacts with a Journal entry
set colResItems = ConItems.Restrict(strFilter)

' Sort the contacts based on LastName
colResItems.Sort "[LastName]"

' Get the number of total items in the Contacts folder
NumItems = colResItems.Count

' Sort the contacts based on LastName
' ConItems.Sort "[LastName]"

' Resize array to handle total number of item in the folder
ReDim FullArray(NumItems-1,4)

' Loop through all of the items in the Contacts folder,
' filling the array with sample data and keeping track
' of the number of contacts found.
NumContacts = 0
For I = 1 to NumItems
Set itm = colResItems(I)
If Left(itm.MessageClass, 11) = "IPM.Contact" Then
NumContacts = NumContacts + 1
FullArray(NumContacts-1,1) = itm.LastName
FullArray(NumContacts-1,2) = itm.User1
FullArray(NumContacts-1,3) = itm.CompanyName
FullArray(NumContacts-1,4) = itm.User2
End If
Next

' Set the control to handle 4 data columns
Control.ColumnCount = 5

If NumItems = NumContacts Then
' They are all contacts, so use the FullArray
Control.List() = FullArray
Else
' There's some distribution lists, so use the smaller
' ConArray to eliminate extra blank values in the list box
Dim ConArray()
ReDim ConArray(NumContacts-1,2)
For I = 0 to NumContacts - 1
ConArray(I,1) = FullArray(I,1)
ConArray(I,2) = FullArray(I,2)
Next
Control.List() = ConArray
End If

End Sub
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
L Outlook 2007 Macro to Run a Script From a Contact Form Using Outlook 41
B Outlook Script ( using calendar function in a form) Outlook VBA and Custom Forms 3
J Outlook Rules VBA Run a Script - Multiple Rules Outlook VBA and Custom Forms 0
N Outlook 2021 'Run Script" Rules? Outlook VBA and Custom Forms 4
G Trigger script without restaring outlook Outlook VBA and Custom Forms 7
D.Moore VB script to Digitaly Sign newly created outlook message Outlook VBA and Custom Forms 2
dweller Outlook 2010 Rule Ignores VBA Script Outlook VBA and Custom Forms 2
B Outlook rule run a Script doesn't work Outlook VBA and Custom Forms 1
K Outlook Archive to PST Files by Date Range VBA Script? Outlook VBA and Custom Forms 1
Vijay Run script doesn't work in outlook Using Outlook 1
F Avoid sending duplicate using Outlook script Outlook VBA and Custom Forms 2
oliv- How to Run a Script IN AN ADDIN with Outlook's Rules and Alerts Outlook VBA and Custom Forms 2
N Outlook script to forward emails based on senders' address Outlook VBA and Custom Forms 2
S using script rule to save attachments on arrival Outlook 2010 Outlook VBA and Custom Forms 9
X Outlook script to run excel data Outlook VBA and Custom Forms 1
N VBA Script to Send Automatic Emails from Outlook 2010 Outlook VBA and Custom Forms 1
D RUN SCRIPT WHEN OUTLOOK IS CLOSE Outlook VBA and Custom Forms 1
P How many subs can run in one outlook VBA script Using Outlook 5
J VBS Script (macro) for word to open Outlook template. Outlook VBA and Custom Forms 2
J Email Parsing VBA Script for Outlook - NEEDED Outlook VBA and Custom Forms 7
J VBS Script: How to execute in Outlook Outlook VBA and Custom Forms 8
Hudas Outlook VBA script reverting back to previous changes Outlook VBA and Custom Forms 2
J Outlook 2007 Rules & VBA: How to run a script on a report message (ReportItem) Using Outlook 14
M Outlook Rule To Redirect Mail - Script to overcome lack of cc's & others Using Outlook 0
C Outlook Script Error Using Outlook 0
S Outlook VBA rule script to process both MailItem and MeetingItem Using Outlook 0
L Limit VBA Script to one Outlook account Using Outlook 1
S Outlook 2010, need script for rules & Warnings Using Outlook 3
C Outlook 200? - Script Export Rules Using Outlook 1
R Change Outlook 2010 Exchange server address via registry or script Using Outlook 5
R Script for simplifying spam control Outlook VBA and Custom Forms 8
K Run a script rule to auto 'send again' on undeliverable emails? Outlook VBA and Custom Forms 1
W Designer Form 2013 and Script ? how ? Outlook VBA and Custom Forms 1
G print attachment straight away; working script edit not working Outlook VBA and Custom Forms 0
G Save attachment run a script rule Outlook VBA and Custom Forms 0
FryW Need help modifying a VBA script for in coming emails to auto set custom reminder time Outlook VBA and Custom Forms 0
G Script does not exist Outlook VBA and Custom Forms 0
A VBA Script - Print Date between first email in Category X and last email in Category Y Outlook VBA and Custom Forms 3
L Modifying VBA script to delay running macro Outlook VBA and Custom Forms 3
L Need help modifying a VBA script for emails stuck in Outbox Outlook VBA and Custom Forms 6
L VB script only runs manually Outlook VBA and Custom Forms 5
E Having some trouble with a run-a-script rule (moving mail based on file type) Outlook VBA and Custom Forms 5
Aussie Rules Run a Script on an Incoming Email OK and then the Email reverts Outlook VBA and Custom Forms 0
D.Moore VBA script fail after Office 365 update Using Outlook 8
M Outlook 2013 Script Assistance - Save Opened Link with Subject Added Outlook VBA and Custom Forms 1
F Script for zip file attachment Outlook VBA and Custom Forms 1
S Change VBA script to send HTML email instead of text Outlook VBA and Custom Forms 3
Y Outlook 2013 Run A Script Outlook VBA and Custom Forms 4
Z Script to set account? Using Outlook 0
N VBA Script to Open highlighted e-mail and Edit Message Outlook VBA and Custom Forms 5

Similar threads

Back
Top