activate contact folder from public folder with "show this folder as email address book using a prf

S

Sue Mosher [MVP-Outlook]

That is not a setting you can manage with a .prf file. Each user would need to run a script to set the ShowAsOutlookAB property for the folder to True.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
F

Frankie K.

Thank you Sue,

i tested the following:

Sub ShowAsAddressBookChange()

Dim olApp As Outlook.Application
Dim nmsName As Outlook.NameSpace
Dim fldFolder As Outlook.MAPIFolder

Set olApp = Outlook.Application
'Create instance of namespace
Set nmsName = olApp.GetNamespace("Mapi")
Set fldFolder = nmsName.GetDefaultFolder(olFolderContacts)
'Display the folder as Outlook Address Book
fldFolder.ShowAsOutlookAB = True

End Sub

Works fine! But how can i set the path to my contact folder in my
public folder. Which objet can i use to set this path?

Thank you in advance!

Best regards,
Frank
 
S

Sue Mosher [MVP-Outlook]

F

Frankie K.

Hi Sue,

if I run the code in Visual Editor it's ok but if i test it with a
double click as a vbs script i get Error 800A0401 line:2 character: 15

Can you help me once more, please?

Sub ShowAsAddressBookChange()
Dim olApp As Outlook.Application
Dim nmsName As Outlook.NameSpace
Dim fldFolder As Outlook.MAPIFolder

Set olApp = Outlook.Application
'Create instance of namespace
Set nmsName = olApp.GetNamespace("Mapi")
'Set fldFolder = GetFolder("Public Folders/All Public
Folders/Company/Sales")
'objNS.GetDefaultFolder(olFolderContacts)
Set fldFolder = GetFolder("Test")
'Display the folder as Outlook Address Book
fldFolder.ShowAsOutlookAB = True
End Sub

Public Function GetFolder(strFolderPath As String) As MAPIFolder
' folder path needs to be something like
' "Public Folders\All Public Folders\Company\Sales"
Dim objApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim colFolders As Outlook.Folders
Dim objFolder As Outlook.MAPIFolder
Dim arrFolders() As String
Dim I As Long
On Error Resume Next
strFolderPath = Replace(strFolderPath, "/", "\")
arrFolders() = Split(strFolderPath, "\")
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objFolder = objNS.Folders.Item(arrFolders(0))
If Not objFolder Is Nothing Then
For I = 1 To UBound(arrFolders)
Set colFolders = objFolder.Folders
Set objFolder = Nothing
Set objFolder = colFolders.Item(arrFolders(I))
If objFolder Is Nothing Then
Exit For
End If
Next
End If
Set GetFolder = objFolder
Set colFolders = Nothing
Set objNS = Nothing
Set objApp = Nothing
End Function

Best regards
Frank
 
S

Sue Mosher [MVP-Outlook]

The VBScript language doesn't support data-typed variable declarations. Comment out all the ' As clauses and use CreateObject("Outlook.Application") to return an Outlook.Application object.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
F

Frankie K.

Hi Sue,

sorry for asking once more but i am not really familiar with VBS.
I used CreateObject as suggested by you but how do i have to adapt your
following code for VBS:

Public Function GetFolder(strFolderPath As String) As MAPIFolder
' folder path needs to be something like
' "Public Folders\All Public Folders\Company\Sales"
Dim objApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim colFolders As Outlook.Folders
Dim objFolder As Outlook.MAPIFolder
Dim arrFolders() As String
Dim I As Long
On Error Resume Next
strFolderPath = Replace(strFolderPath, "/", "\")
arrFolders() = Split(strFolderPath, "\")
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objFolder = objNS.Folders.Item(arrFolders(0))
If Not objFolder Is Nothing Then
For I = 1 To UBound(arrFolders)
Set colFolders = objFolder.Folders
Set objFolder = Nothing
Set objFolder = colFolders.Item(arrFolders(I))
If objFolder Is Nothing Then
Exit For
End If
Next
End If
Set GetFolder = objFolder
Set colFolders = Nothing
Set objNS = Nothing
Set objApp = Nothing
End Function

Thanks in advance.

Best regards,
Frank
 
S

Sue Mosher [MVP-Outlook]

You already did:

Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")

but you still need to get rid of all those As <data/object type> expressions, which are not supported in VBScript.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top