|
|
| Next: Create an adress book to synchronise with a PDA |
| Author |
Message |
PeterGates External

Since: Jun 25, 2009 Posts: 3
|
Posted: Thu Jun 25, 2009 1:53 am Post subject: ShowCategoriesDialog for multiple inbox items Archived from groups: microsoft>public>outlook>program_vba (more info?) |
|
|
I'm trying to set up a macro that opens the Categories dialog for items I
select from the Inbox (or other Outlook folder). Using the code below I can
assign categories for single mail items in turn (ie the dialog opens, I
select categories, they are applied to the first item and then the dialog
opens again for the next item).
Can anyone tell me a way to have the same cateories apply to the multiple
messages I select?
------
Sub ShowCategoriesDialog()
Dim OlExp As Outlook.Explorer
Dim OlSel As Outlook.Selection
Dim x As Integer
Set OlExp = Application.ActiveExplorer
Set OlSel = OlExp.Selection
For x = 1 To OlSel.Count
OlSel.item(x).ShowCategoriesDialog
Next x
End Sub
------ |
|
| Back to top |
|
 |
Sue Mosher [MVP] External

Since: Jun 20, 2009 Posts: 10
|
Posted: Thu Jun 25, 2009 6:34 am Post subject: RE: ShowCategoriesDialog for multiple inbox items [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
I'd move the ShowCategoriesDialog statement so that it runs before the For
.... Next loop. Then use the loop to copy the Categories property value from
the first item to all the rest:
Set firstItem = OlSel.item(1)
firstItem.ShowCategoriesDialog
For x = 2 To OlSel.Count
OlSel.item(x).Categories = firstItem.Categories
Next x
"PeterGates" wrote:
> I'm trying to set up a macro that opens the Categories dialog for items I
> select from the Inbox (or other Outlook folder). Using the code below I can
> assign categories for single mail items in turn (ie the dialog opens, I
> select categories, they are applied to the first item and then the dialog
> opens again for the next item).
>
> Can anyone tell me a way to have the same cateories apply to the multiple
> messages I select?
>
> ------
> Sub ShowCategoriesDialog()
> Dim OlExp As Outlook.Explorer
> Dim OlSel As Outlook.Selection
> Dim x As Integer
>
> Set OlExp = Application.ActiveExplorer
> Set OlSel = OlExp.Selection
>
> For x = 1 To OlSel.Count
> OlSel.item(x).ShowCategoriesDialog
> Next x
> End Sub
> ------ |
|
| Back to top |
|
 |
Ken Slovak - [MVP - Outlo External

Since: Oct 17, 2003 Posts: 3355
|
Posted: Thu Jun 25, 2009 9:29 am Post subject: Re: ShowCategoriesDialog for multiple inbox items [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
Just call to open that dialog once, on the first selected item. Then pull
the categories from the item after the dialog closes and apply those
categories to the remainder of the selection. If you want you can get the
existing categories before you call to open the dialog to be able to compare
and see which were added/removed.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm
"PeterGates" <PeterGates.TakeThisOut@discussions.microsoft.com> wrote in message
news:D876CE7F-D3F8-484E-978D-35066D442F6E@microsoft.com...
> I'm trying to set up a macro that opens the Categories dialog for items I
> select from the Inbox (or other Outlook folder). Using the code below I
> can
> assign categories for single mail items in turn (ie the dialog opens, I
> select categories, they are applied to the first item and then the dialog
> opens again for the next item).
>
> Can anyone tell me a way to have the same cateories apply to the multiple
> messages I select?
>
> ------
> Sub ShowCategoriesDialog()
> Dim OlExp As Outlook.Explorer
> Dim OlSel As Outlook.Selection
> Dim x As Integer
>
> Set OlExp = Application.ActiveExplorer
> Set OlSel = OlExp.Selection
>
> For x = 1 To OlSel.Count
> OlSel.item(x).ShowCategoriesDialog
> Next x
> End Sub
> ------ |
|
| Back to top |
|
 |
PeterGates External

Since: Jun 25, 2009 Posts: 3
|
Posted: Fri Jun 26, 2009 8:44 am Post subject: RE: ShowCategoriesDialog for multiple inbox items [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
Thanks for your help, it was quite a simple solution when I think about it.
It hasn't solved my problem though...
Now when I run the macro I get a dialog for the first item and the newly
added categories are shown (as coloured boxes) in the inbox window against
this first selected mail item only. The others don't appear to pick up a
category.
I added some msgbox lines in to display the categories inside the For-Next
loop and they return that the category is being assigned.
Any idea why this is?
Updated code:
-----
Sub ShowCategoriesDialog()
Dim OlExp As Outlook.Explorer
Dim OlSel As Outlook.Selection
Dim x As Integer
Set OlExp = Application.ActiveExplorer
Set OlSel = OlExp.Selection
Set FirstItem = OlSel.item(1)
FirstItem.ShowCategoriesDialog
MsgBox FirstItem.Categories, , "Item 1 Categories:"
For x = 2 To OlSel.Count
OlSel.item(x).Categories = FirstItem.Categories
MsgBox OlSel.item(x).Categories, , "Item " & x & " Categories:"
Next x
End Sub
-----
"Sue Mosher [MVP]" wrote:
> I'd move the ShowCategoriesDialog statement so that it runs before the For
> ... Next loop. Then use the loop to copy the Categories property value from
> the first item to all the rest:
>
> Set firstItem = OlSel.item(1)
> firstItem.ShowCategoriesDialog
> For x = 2 To OlSel.Count
> OlSel.item(x).Categories = firstItem.Categories
> Next x
>
> "PeterGates" wrote:
>
> > I'm trying to set up a macro that opens the Categories dialog for items I
> > select from the Inbox (or other Outlook folder). Using the code below I can
> > assign categories for single mail items in turn (ie the dialog opens, I
> > select categories, they are applied to the first item and then the dialog
> > opens again for the next item).
> >
> > Can anyone tell me a way to have the same cateories apply to the multiple
> > messages I select?
> >
> > ------
> > Sub ShowCategoriesDialog()
> > Dim OlExp As Outlook.Explorer
> > Dim OlSel As Outlook.Selection
> > Dim x As Integer
> >
> > Set OlExp = Application.ActiveExplorer
> > Set OlSel = OlExp.Selection
> >
> > For x = 1 To OlSel.Count
> > OlSel.item(x).ShowCategoriesDialog
> > Next x
> > End Sub
> > ------ |
|
| Back to top |
|
 |
Sue Mosher [MVP] External

Since: Mar 19, 2009 Posts: 41
|
Posted: Fri Jun 26, 2009 2:24 pm Post subject: Re: ShowCategoriesDialog for multiple inbox items [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
I don't see any OlSel.item(x).Save statement, but that's partially my fault.
I left that out of my loop. Sorry.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
"PeterGates" <PeterGates.RemoveThis@discussions.microsoft.com> wrote in message
news:D4608C67-4C79-41C1-99C1-4B271C8A9943@microsoft.com...
> Thanks for your help, it was quite a simple solution when I think about
> it.
> It hasn't solved my problem though...
>
> Now when I run the macro I get a dialog for the first item and the newly
> added categories are shown (as coloured boxes) in the inbox window against
> this first selected mail item only. The others don't appear to pick up a
> category.
>
> I added some msgbox lines in to display the categories inside the For-Next
> loop and they return that the category is being assigned.
>
> Any idea why this is?
> Updated code:
>
> -----
> Sub ShowCategoriesDialog()
> Dim OlExp As Outlook.Explorer
> Dim OlSel As Outlook.Selection
> Dim x As Integer
>
> Set OlExp = Application.ActiveExplorer
> Set OlSel = OlExp.Selection
> Set FirstItem = OlSel.item(1)
>
> FirstItem.ShowCategoriesDialog
> MsgBox FirstItem.Categories, , "Item 1 Categories:"
>
> For x = 2 To OlSel.Count
> OlSel.item(x).Categories = FirstItem.Categories
> MsgBox OlSel.item(x).Categories, , "Item " & x & " Categories:"
> Next x
> End Sub
> -----
>
>
> "Sue Mosher [MVP]" wrote:
>
>> I'd move the ShowCategoriesDialog statement so that it runs before the
>> For
>> ... Next loop. Then use the loop to copy the Categories property value
>> from
>> the first item to all the rest:
>>
>> Set firstItem = OlSel.item(1)
>> firstItem.ShowCategoriesDialog
>> For x = 2 To OlSel.Count
>> OlSel.item(x).Categories = firstItem.Categories
>> Next x
>>
>> "PeterGates" wrote:
>>
>> > I'm trying to set up a macro that opens the Categories dialog for items
>> > I
>> > select from the Inbox (or other Outlook folder). Using the code below I
>> > can
>> > assign categories for single mail items in turn (ie the dialog opens, I
>> > select categories, they are applied to the first item and then the
>> > dialog
>> > opens again for the next item).
>> >
>> > Can anyone tell me a way to have the same cateories apply to the
>> > multiple
>> > messages I select?
>> >
>> > ------
>> > Sub ShowCategoriesDialog()
>> > Dim OlExp As Outlook.Explorer
>> > Dim OlSel As Outlook.Selection
>> > Dim x As Integer
>> >
>> > Set OlExp = Application.ActiveExplorer
>> > Set OlSel = OlExp.Selection
>> >
>> > For x = 1 To OlSel.Count
>> > OlSel.item(x).ShowCategoriesDialog
>> > Next x
>> > End Sub
>> > ------ |
|
| Back to top |
|
 |
PeterGates External

Since: Jun 25, 2009 Posts: 3
|
Posted: Fri Jun 26, 2009 3:20 pm Post subject: Re: ShowCategoriesDialog for multiple inbox items [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
Absolutely no apologies needed, you've helped an Outlook VBA novice out a
lot. I doubt this will be my last post - I have a few ideas I want to try and
implement...
Many thanks and best wishes.
Peter
"Sue Mosher [MVP]" wrote:
> I don't see any OlSel.item(x).Save statement, but that's partially my fault.
> I left that out of my loop. Sorry.
>
> --
> Sue Mosher, Outlook MVP
> Author of Microsoft Outlook 2007 Programming:
> Jumpstart for Power Users and Administrators
> http://www.outlookcode.com/article.aspx?id=54
>
>
> "PeterGates" <PeterGates.TakeThisOut@discussions.microsoft.com> wrote in message
> news:D4608C67-4C79-41C1-99C1-4B271C8A9943@microsoft.com...
> > Thanks for your help, it was quite a simple solution when I think about
> > it.
> > It hasn't solved my problem though...
> >
> > Now when I run the macro I get a dialog for the first item and the newly
> > added categories are shown (as coloured boxes) in the inbox window against
> > this first selected mail item only. The others don't appear to pick up a
> > category.
> >
> > I added some msgbox lines in to display the categories inside the For-Next
> > loop and they return that the category is being assigned.
> >
> > Any idea why this is?
> > Updated code:
> >
> > -----
> > Sub ShowCategoriesDialog()
> > Dim OlExp As Outlook.Explorer
> > Dim OlSel As Outlook.Selection
> > Dim x As Integer
> >
> > Set OlExp = Application.ActiveExplorer
> > Set OlSel = OlExp.Selection
> > Set FirstItem = OlSel.item(1)
> >
> > FirstItem.ShowCategoriesDialog
> > MsgBox FirstItem.Categories, , "Item 1 Categories:"
> >
> > For x = 2 To OlSel.Count
> > OlSel.item(x).Categories = FirstItem.Categories
> > MsgBox OlSel.item(x).Categories, , "Item " & x & " Categories:"
> > Next x
> > End Sub
> > -----
> >
> >
> > "Sue Mosher [MVP]" wrote:
> >
> >> I'd move the ShowCategoriesDialog statement so that it runs before the
> >> For
> >> ... Next loop. Then use the loop to copy the Categories property value
> >> from
> >> the first item to all the rest:
> >>
> >> Set firstItem = OlSel.item(1)
> >> firstItem.ShowCategoriesDialog
> >> For x = 2 To OlSel.Count
> >> OlSel.item(x).Categories = firstItem.Categories
> >> Next x
> >>
> >> "PeterGates" wrote:
> >>
> >> > I'm trying to set up a macro that opens the Categories dialog for items
> >> > I
> >> > select from the Inbox (or other Outlook folder). Using the code below I
> >> > can
> >> > assign categories for single mail items in turn (ie the dialog opens, I
> >> > select categories, they are applied to the first item and then the
> >> > dialog
> >> > opens again for the next item).
> >> >
> >> > Can anyone tell me a way to have the same cateories apply to the
> >> > multiple
> >> > messages I select?
> >> >
> >> > ------
> >> > Sub ShowCategoriesDialog()
> >> > Dim OlExp As Outlook.Explorer
> >> > Dim OlSel As Outlook.Selection
> >> > Dim x As Integer
> >> >
> >> > Set OlExp = Application.ActiveExplorer
> >> > Set OlSel = OlExp.Selection
> >> >
> >> > For x = 1 To OlSel.Count
> >> > OlSel.item(x).ShowCategoriesDialog
> >> > Next x
> >> > End Sub
> >> > ------
>
>
> |
|
| Back to top |
|
 |
|
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
| |
|
|