Create VbaProject.OTM - VBA project for Outlook in C:\Documents and
Settings\%username%\Application Data\Microsoft\Outlook\
Open Outlook and press Alt+F11 to open VbaProject.OTM
Paste this code into ThisOutlookSession Startup event
=====================================================
Private Sub Application_Startup()
' NAME: WSS StsSyncAddOn
'
' AUTHOR : Shilov Pavel (e-mail address removed)
' DATE : 14.02.2006
' VERSION : 1.0.1
'
' COMMENT: Script to sync WSS contact lists. This script must be executed
' on Outlook startup. It opens all WSS contact list folders in
Outlook
' and sync data with SharePoint
'
Dim strMsg1, strMsg2 As String
Dim olApp As New Outlook.Application
Dim oNS As Outlook.NameSpace
Dim fldFolder As Outlook.MAPIFolder
Dim fldFolder1 As Outlook.MAPIFolder
Dim expContacts As Outlook.Explorer
Dim Response
Dim arrAppVer
On Error Resume Next
arrAppVer = Split(olApp.Version, ".")
If CInt(arrAppVer(0)) < 11 Then Exit Sub
strMsg1 = "Outlook should synchronize SharePoint contact lists." &
Chr(13) & Chr(10) & "This can take some minutes" & Chr(13) & Chr(10) &
"Continue?"
strMsg2 = "Contact lists have been synchronized successfully."
Set oNS = olApp.GetNamespace("MAPI")
For Each fldFolder In oNS.Folders
If fldFolder.IsSharePointFolder = True Then
If fldFolder.Folders.Count < 1 Then Exit Sub
Response = MsgBox(strMsg1, vbOKCancel + vbInformation +
vbDefaultButton2, "WSS StsSyncAddOn")
If Response = vbOK Then
For Each fldFolder1 In fldFolder.Folders
Set expContacts = fldFolder1.GetExplorer
expContacts.Activate
expContacts.Close
Next
Response = MsgBox(strMsg2, vbOKOnly + vbInformation, "WSS
StsSyncAddOn")
End If
End If
Next
On Error GoTo 0
End Sub
=====================================================
Sign code with digital signature from your MS CertSrv of your Domain
Use this script to distribute VbaProject.OTM
'==========================================================================
'
' NAME: VBA OTM distribute
'
' AUTHOR: Shilov Pavel , (e-mail address removed)
' DATE : 21.02.2006
' VER : 1.0.1
' COMMENT:
'
'==========================================================================
On Error Resume Next
Dim strPath, strPathToCopy, strFileName, strOfficeKey, res, WSHShell
strPath = "%Yuor share folder%"
strFileName = "Install.cmd"
strOutlookFName1 = "VbaProject.OTM"
strOutlookFName2 = "outcmd.dat"
strOfficeKey =
"HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Outlook\UserInfo\UserInfo"
set WSHShell = WScript.CreateObject("WScript.Shell")
strAgent = WSHShell.RegRead (strOfficeKey)
If Err = 0 Then
Set oFS = CreateObject("Scripting.FileSystemObject")
Set oDir = oFS.GetFolder(WSHShell.ExpandEnvironmentStrings("%APPDATA%") &
"\Microsoft\Outlook\")
Set oFiles = oDir.Files
For Each of In oFiles
If (of.Name = strOutlookFName1) Or (of.Name = strOutlookFName2) Then
of.Name = Left(of.Name,Len(of.Name)-3) & "back"
End If
Next
cmd = CHR(34) & strPath & strFileName & Chr(34)
res = WshShell.Run(cmd,0,True)
End If
Set WshShell = Nothing
On Error Goto 0
=======================================================
Install.cmd
Copy %YourShareFolder%\VbaProject.OTM "%APPDATA%\Microsoft\Outlook\" /y
Copy %YourShareFolder%\outcmd.dat "%APPDATA%\Microsoft\Outlook\" /y