I have a VB Script routine that runs (as code behind forms) when I open the contact form in Outlook 2000. The purpose of the code is to load a list of telephone numbers into an array which is used to validate phone numbers in the address book.
It works fine now but I would like to have the routine execute when the Outlook application opens rather than when the contact form opens.
I assume that this will have to be done in VBA rather than the VB Script code behind forms. I have included my VB Script code below followed by a sample of the data file text it reads from a file.
Can anyone give me a pointer on how to convert this to VBA and execute it when Outlook opens? Any help appreciated.
Sample code
--------------------------------------------------
Option Explicit
'global variable holding array of phone numbers not to call
Public strNoCallArray(20000)
Function Item_Open()
Dim strPnumber
Dim fso 'file system object
Dim f 'file
Dim ts 'text stream
Dim c 'counter
'
Dim ArrayIndex
set fso = CreateObject("Scripting.FileSystemObject"
set f = fso.GetFile("c:\donotcall1.txt"
set ts = f.OpenAsTextStream
c = 0
'
Do While Not ts.AtEndOfStream
strPnumber = ""
strPnumber = strPnumber & ts.ReadLine
'remove area code from phone number
strPnumber = """" & Mid(strPnumber, 4, 7) & """"
strNoCallArray(c) = strPnumber
c = c + 1
Loop
'
msgbox("all done"
'
ts.close
End Function
Note that the the text file being loaded is a list of phone numbers in the format:
7278885555
7274449999
7274443333
---------------------------------
Art Madden
amadden@tampabay.rr.com
It works fine now but I would like to have the routine execute when the Outlook application opens rather than when the contact form opens.
I assume that this will have to be done in VBA rather than the VB Script code behind forms. I have included my VB Script code below followed by a sample of the data file text it reads from a file.
Can anyone give me a pointer on how to convert this to VBA and execute it when Outlook opens? Any help appreciated.
Sample code
--------------------------------------------------
Option Explicit
'global variable holding array of phone numbers not to call
Public strNoCallArray(20000)
Function Item_Open()
Dim strPnumber
Dim fso 'file system object
Dim f 'file
Dim ts 'text stream
Dim c 'counter
'
Dim ArrayIndex
set fso = CreateObject("Scripting.FileSystemObject"
set f = fso.GetFile("c:\donotcall1.txt"
set ts = f.OpenAsTextStream
c = 0
'
Do While Not ts.AtEndOfStream
strPnumber = ""
strPnumber = strPnumber & ts.ReadLine
'remove area code from phone number
strPnumber = """" & Mid(strPnumber, 4, 7) & """"
strNoCallArray(c) = strPnumber
c = c + 1
Loop
'
msgbox("all done"
'
ts.close
End Function
Note that the the text file being loaded is a list of phone numbers in the format:
7278885555
7274449999
7274443333
---------------------------------
Art Madden
amadden@tampabay.rr.com