PC Review Forums Newsgroups Microsoft Outlook Microsoft Outlook VBA Programming Cannot convert all contacts, in a public folder, to a new form...

Reply

Cannot convert all contacts, in a public folder, to a new form...

 
Thread Tools Rate Thread
Old 30-04-2004, 05:37 PM   #1
Valentin
Guest
 
Posts: n/a
Default Cannot convert all contacts, in a public folder, to a new form...


Hi all!

I have a public folder that contains contacts. I was asked to change
the contacts from the default form to a slightly different form, more
specifically, one that wouldn't show the Certificates tab.
I modified the default Contact form and published it as
Custom_Contact_View and then I ran a VBA procedure that I found in
section 24.1.3 in the book "Microsoft Outlook Programming"(written by
Sue Mosher). The procedure ran without a hitch, but when I started
opening the contacts, I discovered that some of them had not been
converted. I checked and all items in the public folder are of type
"Contact", so, what could be the problem?

This is the code that I used:
'=============================================================
' UpdateMessageClass
' Listing 24.3
'-------------------------------------------------------------
' Purpose : Apply a new form to existing items
' Notes : Assumes g_CDOSession MAPI.Session global variable
' uses reference to Microsoft CDO 1.21 Library (cdo.dll)
'=============================================================
Sub UpdateMessageClass()
Dim objApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim objFolder As Outlook.MAPIFolder
Dim objCDOFolder As MAPI.Folder
Dim colCDOMessages As MAPI.Messages
Dim objCDOMessage As MAPI.Message
Dim objFilter As MAPI.MessageFilter
Dim strClass As String
Dim strFolderClass As String
Dim strMsg As String
Dim strTitle As String

Dim iCntr As Integer

On Error Resume Next

iCntr = 0
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objFolder = objNS.PickFolder
If Not objFolder Is Nothing Then
strMsg = "Change all items in folder to what class?"
strTitle = "UpdateMessageClass"
strClass = InputBox(strMsg, strTitle)
strFolderClass = objFolder.DefaultMessageClass
'MsgBox strFolderClass
If InStr(1, strClass, strFolderClass, _
vbTextCompare) Then
Call DoCDOLogon
Set objCDOFolder = _
g_CDOSession.GetFolder(objFolder.EntryID, _
objFolder.StoreID)
Set colCDOMessages = objCDOFolder.Messages
Set objFilter = colCDOMessages.Filter
objFilter.Type = strFolderClass
For Each objCDOMessage In colCDOMessages
objCDOMessage.Type = strClass
objCDOMessage.Update
Next
Call DoCDOLogoff
strMsg = "Updated items in " & objFolder.Name & " Folder"
MsgBox strMsg, , strTitle
Else
strMsg = "The class you specified is not the normal " & _
"type for this folder. " & _
"No items will be updated."
MsgBox strMsg, , strTitle
End If
End If

Set objFolder = Nothing
Set objCDOFolder = Nothing
Set objCDOMessage = Nothing
Set colCDOMessages = Nothing
Set objFilter = Nothing
Set objNS = Nothing
Set objApp = Nothing
End Sub
  Reply With Quote
Old 30-04-2004, 06:52 PM   #2
Sue Mosher [MVP-Outlook]
Guest
 
Posts: n/a
Default Re: Cannot convert all contacts, in a public folder, to a new form...

I would suggest that you step through the code in the VBA debugger so you
can follow the logic and discover what's not working as expected. Remarking
out the On Error Resume Next line would also be a good troubleshooting
technique -- so you can be notified of any errors.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"Valentin" <valentin_ionita@yahoo.com> wrote in message
news:f1869211.0404300837.415608a5@posting.google.com...
> Hi all!
>
> I have a public folder that contains contacts. I was asked to change
> the contacts from the default form to a slightly different form, more
> specifically, one that wouldn't show the Certificates tab.
> I modified the default Contact form and published it as
> Custom_Contact_View and then I ran a VBA procedure that I found in
> section 24.1.3 in the book "Microsoft Outlook Programming"(written by
> Sue Mosher). The procedure ran without a hitch, but when I started
> opening the contacts, I discovered that some of them had not been
> converted. I checked and all items in the public folder are of type
> "Contact", so, what could be the problem?
>
> This is the code that I used:
> '=============================================================
> ' UpdateMessageClass
> ' Listing 24.3
> '-------------------------------------------------------------
> ' Purpose : Apply a new form to existing items
> ' Notes : Assumes g_CDOSession MAPI.Session global variable
> ' uses reference to Microsoft CDO 1.21 Library (cdo.dll)
> '=============================================================
> Sub UpdateMessageClass()
> Dim objApp As Outlook.Application
> Dim objNS As Outlook.NameSpace
> Dim objFolder As Outlook.MAPIFolder
> Dim objCDOFolder As MAPI.Folder
> Dim colCDOMessages As MAPI.Messages
> Dim objCDOMessage As MAPI.Message
> Dim objFilter As MAPI.MessageFilter
> Dim strClass As String
> Dim strFolderClass As String
> Dim strMsg As String
> Dim strTitle As String
>
> Dim iCntr As Integer
>
> On Error Resume Next
>
> iCntr = 0
> Set objApp = CreateObject("Outlook.Application")
> Set objNS = objApp.GetNamespace("MAPI")
> Set objFolder = objNS.PickFolder
> If Not objFolder Is Nothing Then
> strMsg = "Change all items in folder to what class?"
> strTitle = "UpdateMessageClass"
> strClass = InputBox(strMsg, strTitle)
> strFolderClass = objFolder.DefaultMessageClass
> 'MsgBox strFolderClass
> If InStr(1, strClass, strFolderClass, _
> vbTextCompare) Then
> Call DoCDOLogon
> Set objCDOFolder = _
> g_CDOSession.GetFolder(objFolder.EntryID, _
> objFolder.StoreID)
> Set colCDOMessages = objCDOFolder.Messages
> Set objFilter = colCDOMessages.Filter
> objFilter.Type = strFolderClass
> For Each objCDOMessage In colCDOMessages
> objCDOMessage.Type = strClass
> objCDOMessage.Update
> Next
> Call DoCDOLogoff
> strMsg = "Updated items in " & objFolder.Name & " Folder"
> MsgBox strMsg, , strTitle
> Else
> strMsg = "The class you specified is not the normal " & _
> "type for this folder. " & _
> "No items will be updated."
> MsgBox strMsg, , strTitle
> End If
> End If
>
> Set objFolder = Nothing
> Set objCDOFolder = Nothing
> Set objCDOMessage = Nothing
> Set colCDOMessages = Nothing
> Set objFilter = Nothing
> Set objNS = Nothing
> Set objApp = Nothing
> End Sub



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off