PC Review


Reply
Thread Tools Rate Thread

delete a folder from my contacts in Outlook VBA

 
 
=?Utf-8?B?U2Vhbg==?=
Guest
Posts: n/a
 
      7th Oct 2005
I am using VBA to create and delete folders in the default contact folder.
This seems to be working fine - the new folder is always created and the
items that I generate are included in the new folder.

The problem is that when I go into the Contacts folder in Outlook Explorer I
still see the old folder in My Contacts. When I click on the old entry
Explorer says that the folder has been deleted. So how do I remove the
reference to this folder from My Contacts.

The old folder also persists in the list of folders to be used as an address
book.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?RXJpYyBMZWdhdWx0IFtNVlAgLSBPdXRsb29rXQ==
Guest
Posts: n/a
 
      7th Oct 2005
Strange, I can't reproduce this at all. Can you show your code? What is
your full Outlook version and build number?

--
Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"Sean" wrote:

> I am using VBA to create and delete folders in the default contact folder.
> This seems to be working fine - the new folder is always created and the
> items that I generate are included in the new folder.
>
> The problem is that when I go into the Contacts folder in Outlook Explorer I
> still see the old folder in My Contacts. When I click on the old entry
> Explorer says that the folder has been deleted. So how do I remove the
> reference to this folder from My Contacts.
>
> The old folder also persists in the list of folders to be used as an address
> book.

 
Reply With Quote
 
Sue Mosher [MVP-Outlook]
Guest
Posts: n/a
 
      7th Oct 2005
There is an Explorer.DeselectFolder method. See http://msdn.microsoft.com/library/en...ctFolder1..asp

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


"Sean" <(E-Mail Removed)> wrote in message news9F06893-397A-4B77-BB0E-(E-Mail Removed)...
>I am using VBA to create and delete folders in the default contact folder.
> This seems to be working fine - the new folder is always created and the
> items that I generate are included in the new folder.
>
> The problem is that when I go into the Contacts folder in Outlook Explorer I
> still see the old folder in My Contacts. When I click on the old entry
> Explorer says that the folder has been deleted. So how do I remove the
> reference to this folder from My Contacts.
>
> The old folder also persists in the list of folders to be used as an address
> book.

 
Reply With Quote
 
=?Utf-8?B?U2Vhbg==?=
Guest
Posts: n/a
 
      9th Oct 2005
Thank you for looking at this for me.

I am running Outlook 2003 (11.6568.6568) SP2

Here is a version of the code:
Dim ol_app As New Outlook.Application
Dim ol_namespace As Outlook.Namespace
Dim ol_folder_contacts As Outlook.MAPIFolder
Dim ol_folder_volunteers As Outlook.MAPIFolder
Dim ol_xplorer As Outlook.Explorer
Dim ol_dist_list As Outlook.DistListItem
Dim ol_recipient As Outlook.Recipient
Dim ol_temp_mail As Outlook.MailItem
Dim sycs As Outlook.SyncObjects
Dim syc As Outlook.SyncObject
Dim rs As New ADODB.Recordset
Dim first_up As Boolean
Dim prevGroup As String
Dim i As Long

DoCmd.Hourglass True
Set ol_namespace = ol_app.GetNamespace("MAPI")
Set ol_folder_contacts = ol_namespace.GetDefaultFolder(olFolderContacts)

For i = 1 To ol_folder_contacts.Folders.Count
If ol_folder_contacts.Folders(i) = "Volunteers" Then
Set ol_folder_volunteers = ol_folder_contacts.Folders(i)
ol_folder_volunteers.ShowAsOutlookAB = False
Set ol_folder_volunteers = Nothing
ol_folder_contacts.Folders.Remove i
Exit For
End If
Next

Set ol_folder_volunteers = ol_folder_contacts.Folders.Add("Volunteers")
ol_folder_volunteers.ShowAsOutlookAB = True



Note that the code is acutally running in Access - not Outlook. What I am
trying to acheive is having my Access App generate a new Volunteers folder
and populate it with a contacts.

As I said in the original post - everything seems to be working except that
the old folder still appears under My Contacts.

Usually I do not have Outlook Explorer running while I run the code in
Access. So I first see the problem when I launch the Outlook and goto the
Contacts Folder.

Another aspect of the problem is that it appears to correct itself over
time. Eventually the old folder will disappear. It usually take about 30
minutes to do so - with Outlook explorer not active.

Again - thanks for looking at this.

Sean




"Eric Legault [MVP - Outlook]" wrote:

> Strange, I can't reproduce this at all. Can you show your code? What is
> your full Outlook version and build number?
>
> --
> Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.)
> Try Picture Attachments Wizard for Outlook:
> http://www.collaborativeinnovations.ca
> Blog: http://blogs.officezealot.com/legault/
>
>
> "Sean" wrote:
>
> > I am using VBA to create and delete folders in the default contact folder.
> > This seems to be working fine - the new folder is always created and the
> > items that I generate are included in the new folder.
> >
> > The problem is that when I go into the Contacts folder in Outlook Explorer I
> > still see the old folder in My Contacts. When I click on the old entry
> > Explorer says that the folder has been deleted. So how do I remove the
> > reference to this folder from My Contacts.
> >
> > The old folder also persists in the list of folders to be used as an address
> > book.

 
Reply With Quote
 
=?Utf-8?B?U2Vhbg==?=
Guest
Posts: n/a
 
      9th Oct 2005
Thanks for looking at this. I re-posted a fuller description of the problem
in a reponse to Eric's post.

When I tried what you suggested I errored out. This is because I don't have
an exlporer active at the time that I run the code in Access.

Sean

"Sue Mosher [MVP-Outlook]" wrote:

> There is an Explorer.DeselectFolder method. See http://msdn.microsoft.com/library/en...ctFolder1..asp
>
> --
> Sue Mosher, Outlook MVP
> Author of Configuring Microsoft Outlook 2003
> http://www.turtleflock.com/olconfig/index.htm
> and Microsoft Outlook Programming - Jumpstart for
> Administrators, Power Users, and Developers
> http://www.outlookcode.com/jumpstart.aspx
>
>
> "Sean" <(E-Mail Removed)> wrote in message news9F06893-397A-4B77-BB0E-(E-Mail Removed)...
> >I am using VBA to create and delete folders in the default contact folder.
> > This seems to be working fine - the new folder is always created and the
> > items that I generate are included in the new folder.
> >
> > The problem is that when I go into the Contacts folder in Outlook Explorer I
> > still see the old folder in My Contacts. When I click on the old entry
> > Explorer says that the folder has been deleted. So how do I remove the
> > reference to this folder from My Contacts.
> >
> > The old folder also persists in the list of folders to be used as an address
> > book.

>

 
Reply With Quote
 
Sue Mosher [MVP-Outlook]
Guest
Posts: n/a
 
      9th Oct 2005
So, what happens if you show an Explorer and perform the operation, then close it?

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


"Sean" <(E-Mail Removed)> wrote in message news:FCE7F8E5-5171-42FF-85DA-(E-Mail Removed)...
> Thanks for looking at this. I re-posted a fuller description of the problem
> in a reponse to Eric's post.
>
> When I tried what you suggested I errored out. This is because I don't have
> an exlporer active at the time that I run the code in Access.
>
> Sean
>
> "Sue Mosher [MVP-Outlook]" wrote:
>
>> There is an Explorer.DeselectFolder method. See http://msdn.microsoft.com/library/en...tFolder1...asp


>>
>> "Sean" <(E-Mail Removed)> wrote in message news9F06893-397A-4B77-BB0E-(E-Mail Removed)...
>> >I am using VBA to create and delete folders in the default contact folder.
>> > This seems to be working fine - the new folder is always created and the
>> > items that I generate are included in the new folder.
>> >
>> > The problem is that when I go into the Contacts folder in Outlook Explorer I
>> > still see the old folder in My Contacts. When I click on the old entry
>> > Explorer says that the folder has been deleted. So how do I remove the
>> > reference to this folder from My Contacts.
>> >
>> > The old folder also persists in the list of folders to be used as an address
>> > book.

>>

 
Reply With Quote
 
=?Utf-8?B?U2Vhbg==?=
Guest
Posts: n/a
 
      9th Oct 2005
More bad stuff happens. I get a runtime error C2004005 saying that "The
folder selections was not cleared. At least one folder must remain selected.

I added extra code to select another folder prior to the deselect. I could
see that this folder was selected, and it's contents displayed. But I still
got the same error.

Sean

"Sue Mosher [MVP-Outlook]" wrote:

> So, what happens if you show an Explorer and perform the operation, then close it?
>
> --
> Sue Mosher, Outlook MVP
> Author of Configuring Microsoft Outlook 2003
> http://www.turtleflock.com/olconfig/index.htm
> and Microsoft Outlook Programming - Jumpstart for
> Administrators, Power Users, and Developers
> http://www.outlookcode.com/jumpstart.aspx
>
>
> "Sean" <(E-Mail Removed)> wrote in message news:FCE7F8E5-5171-42FF-85DA-(E-Mail Removed)...
> > Thanks for looking at this. I re-posted a fuller description of the problem
> > in a reponse to Eric's post.
> >
> > When I tried what you suggested I errored out. This is because I don't have
> > an exlporer active at the time that I run the code in Access.
> >
> > Sean
> >
> > "Sue Mosher [MVP-Outlook]" wrote:
> >
> >> There is an Explorer.DeselectFolder method. See http://msdn.microsoft.com/library/en...tFolder1...asp

>
> >>
> >> "Sean" <(E-Mail Removed)> wrote in message news9F06893-397A-4B77-BB0E-(E-Mail Removed)...
> >> >I am using VBA to create and delete folders in the default contact folder.
> >> > This seems to be working fine - the new folder is always created and the
> >> > items that I generate are included in the new folder.
> >> >
> >> > The problem is that when I go into the Contacts folder in Outlook Explorer I
> >> > still see the old folder in My Contacts. When I click on the old entry
> >> > Explorer says that the folder has been deleted. So how do I remove the
> >> > reference to this folder from My Contacts.
> >> >
> >> > The old folder also persists in the list of folders to be used as an address
> >> > book.
> >>

>

 
Reply With Quote
 
Sue Mosher [MVP-Outlook]
Guest
Posts: n/a
 
      10th Oct 2005
How about showing a code snippet that others can try?

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


"Sean" <(E-Mail Removed)> wrote in message news:EAD5160C-AC15-4DDF-B31E-(E-Mail Removed)...
> More bad stuff happens. I get a runtime error C2004005 saying that "The
> folder selections was not cleared. At least one folder must remain selected.
>
> I added extra code to select another folder prior to the deselect. I could
> see that this folder was selected, and it's contents displayed. But I still
> got the same error.
>
> Sean
>
> "Sue Mosher [MVP-Outlook]" wrote:
>
>> So, what happens if you show an Explorer and perform the operation, then close it?
>>
>> "Sean" <(E-Mail Removed)> wrote in message news:FCE7F8E5-5171-42FF-85DA-(E-Mail Removed)...
>> > Thanks for looking at this. I re-posted a fuller description of the problem
>> > in a reponse to Eric's post.
>> >
>> > When I tried what you suggested I errored out. This is because I don't have
>> > an exlporer active at the time that I run the code in Access.
>> >
>> > Sean
>> >
>> > "Sue Mosher [MVP-Outlook]" wrote:
>> >
>> >> There is an Explorer.DeselectFolder method. See http://msdn.microsoft.com/library/en...Folder1....asp

>>
>> >>
>> >> "Sean" <(E-Mail Removed)> wrote in message news9F06893-397A-4B77-BB0E-(E-Mail Removed)...
>> >> >I am using VBA to create and delete folders in the default contact folder.
>> >> > This seems to be working fine - the new folder is always created and the
>> >> > items that I generate are included in the new folder.
>> >> >
>> >> > The problem is that when I go into the Contacts folder in Outlook Explorer I
>> >> > still see the old folder in My Contacts. When I click on the old entry
>> >> > Explorer says that the folder has been deleted. So how do I remove the
>> >> > reference to this folder from My Contacts.
>> >> >
>> >> > The old folder also persists in the list of folders to be used as an address
>> >> > book.
>> >>

>>

 
Reply With Quote
 
=?Utf-8?B?U2Vhbg==?=
Guest
Posts: n/a
 
      10th Oct 2005
There is sample code in my reply to Eric.

Sean

"Sue Mosher [MVP-Outlook]" wrote:

> How about showing a code snippet that others can try?
>
> --
> Sue Mosher, Outlook MVP
> Author of Configuring Microsoft Outlook 2003
> http://www.turtleflock.com/olconfig/index.htm
> and Microsoft Outlook Programming - Jumpstart for
> Administrators, Power Users, and Developers
> http://www.outlookcode.com/jumpstart.aspx
>
>
> "Sean" <(E-Mail Removed)> wrote in message news:EAD5160C-AC15-4DDF-B31E-(E-Mail Removed)...
> > More bad stuff happens. I get a runtime error C2004005 saying that "The
> > folder selections was not cleared. At least one folder must remain selected.
> >
> > I added extra code to select another folder prior to the deselect. I could
> > see that this folder was selected, and it's contents displayed. But I still
> > got the same error.
> >
> > Sean
> >
> > "Sue Mosher [MVP-Outlook]" wrote:
> >
> >> So, what happens if you show an Explorer and perform the operation, then close it?
> >>
> >> "Sean" <(E-Mail Removed)> wrote in message news:FCE7F8E5-5171-42FF-85DA-(E-Mail Removed)...
> >> > Thanks for looking at this. I re-posted a fuller description of the problem
> >> > in a reponse to Eric's post.
> >> >
> >> > When I tried what you suggested I errored out. This is because I don't have
> >> > an exlporer active at the time that I run the code in Access.
> >> >
> >> > Sean
> >> >
> >> > "Sue Mosher [MVP-Outlook]" wrote:
> >> >
> >> >> There is an Explorer.DeselectFolder method. See http://msdn.microsoft.com/library/en...Folder1....asp
> >>
> >> >>
> >> >> "Sean" <(E-Mail Removed)> wrote in message news9F06893-397A-4B77-BB0E-(E-Mail Removed)...
> >> >> >I am using VBA to create and delete folders in the default contact folder.
> >> >> > This seems to be working fine - the new folder is always created and the
> >> >> > items that I generate are included in the new folder.
> >> >> >
> >> >> > The problem is that when I go into the Contacts folder in Outlook Explorer I
> >> >> > still see the old folder in My Contacts. When I click on the old entry
> >> >> > Explorer says that the folder has been deleted. So how do I remove the
> >> >> > reference to this folder from My Contacts.
> >> >> >
> >> >> > The old folder also persists in the list of folders to be used as an address
> >> >> > book.
> >> >>
> >>

>

 
Reply With Quote
 
Sue Mosher [MVP-Outlook]
Guest
Posts: n/a
 
      10th Oct 2005
But that doesn't show deselecting the folder in an Explorer. I'd try showing the user's Contacts folder in an Explorer, deselecting the folder you're interested in, and then closing the Explorer.

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


"Sean" <(E-Mail Removed)> wrote in message news:0111D986-E5C4-437B-800F-(E-Mail Removed)...
> There is sample code in my reply to Eric.
>
> Sean
>
> "Sue Mosher [MVP-Outlook]" wrote:
>
>> How about showing a code snippet that others can try?
>>
>> "Sean" <(E-Mail Removed)> wrote in message news:EAD5160C-AC15-4DDF-B31E-(E-Mail Removed)...
>> > More bad stuff happens. I get a runtime error C2004005 saying that "The
>> > folder selections was not cleared. At least one folder must remain selected.
>> >
>> > I added extra code to select another folder prior to the deselect. I could
>> > see that this folder was selected, and it's contents displayed. But I still
>> > got the same error.
>> >
>> > Sean
>> >
>> > "Sue Mosher [MVP-Outlook]" wrote:
>> >
>> >> So, what happens if you show an Explorer and perform the operation, then close it?
>> >>
>> >> "Sean" <(E-Mail Removed)> wrote in message news:FCE7F8E5-5171-42FF-85DA-(E-Mail Removed)...
>> >> > Thanks for looking at this. I re-posted a fuller description of the problem
>> >> > in a reponse to Eric's post.
>> >> >
>> >> > When I tried what you suggested I errored out. This is because I don't have
>> >> > an exlporer active at the time that I run the code in Access.
>> >> >
>> >> > Sean
>> >> >
>> >> > "Sue Mosher [MVP-Outlook]" wrote:
>> >> >
>> >> >> There is an Explorer.DeselectFolder method. See http://msdn.microsoft.com/library/en...older1.....asp
>> >>
>> >> >>
>> >> >> "Sean" <(E-Mail Removed)> wrote in message news9F06893-397A-4B77-BB0E-(E-Mail Removed)...
>> >> >> >I am using VBA to create and delete folders in the default contact folder.
>> >> >> > This seems to be working fine - the new folder is always created and the
>> >> >> > items that I generate are included in the new folder.
>> >> >> >
>> >> >> > The problem is that when I go into the Contacts folder in Outlook Explorer I
>> >> >> > still see the old folder in My Contacts. When I click on the old entry
>> >> >> > Explorer says that the folder has been deleted. So how do I remove the
>> >> >> > reference to this folder from My Contacts.
>> >> >> >
>> >> >> > The old folder also persists in the list of folders to be used as an address
>> >> >> > book.
>> >> >>
>> >>

>>

 
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I undo a delete from Contacts folder from Outlook 2007? Steve Microsoft Outlook Discussion 11 1st Feb 2010 10:28 AM
Can't delete a contacts folder =?Utf-8?B?dGNhcnA=?= Microsoft Outlook Contacts 1 17th Mar 2007 12:12 PM
How do I delete contacts that aren't in a contacts folder? =?Utf-8?B?TWFyZ2FyZXQ=?= Microsoft Outlook Contacts 1 9th Nov 2006 04:02 PM
How can I delete duplicates in my Outlook 2003 contacts folder? Don Smith Microsoft Outlook 2 6th Oct 2006 03:12 AM
Outlook Contacts show in contacts folder in folder list, not in se =?Utf-8?B?cGFjYXpv?= Microsoft Outlook Contacts 1 16th Dec 2004 05:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:35 PM.