If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
Get a list of all the toolbars currently displaying in Outlook
I would like to make a Sub that will return all the toolbars in Outlook
currently displaying with VBA. The reason why I'd like to do this is because I have a COM called SpamBayes whose toolbar appears in the Outlook User Interface. The way this works is it inspects each New Mail and if it satisfies the criterion that the New Mail is spam it sends the e-mail to a folder called Junk E-Mail. I have set up some code so that the ItemAdd event for that folder will delete it entirely if the e-mail goes to that folder. Works well. But if some e-mail comes in that SpamBayes is unsure about the e-mail will go to a folder called Junk Suspects. Then in the toolbar provided by SpamBayes with the suspect e-mail selected, I can hit a buttom called Spam which sends the e-mail to the Junk E-Mail folder and the Bayesian criteria is satisfied. If it is not Spam I hit the button in the toolbar called Not Spam and the selected e-mail is put back in the Inbox. Both these buttons appear when the e-mail is in the Junk Suspects and is in that current folder but otherwise the button Spam always appears. What I would like to do is push the button Spam programatically that the selected e-mail (the item) is Junk E-Mail. It's ok this thing works pretty good so that 99% of all suspected e-mail is in fact Spam. But I think I need to know what the caption is for this toolbar. If I know that maybe I can hit the button programatically which will set the e-mail as spam and my other program will get rid of it. So is there a way to get a description (the caption) of each of the toolbars currently displaying in Outlook? Thanks. -- George Hester _________________________________ |
Ads |
#2
|
|||
|
|||
Get a list of all the toolbars currently displaying in Outlook
Open one e-mail and look for the comandbars name. In code you can then access the bar with: Dim cb as Office.Commandbar set cb=Application.ActiveExplorer.Selection(1).Command bars("TheName") If the bar exists and is visible then get its button 1 or 2 and call its Execute method. -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook Keep your Outlook categories organized! http://www.shareit.com/product.html?...4&languageid=1 (German: http://www.VBOffice.net/product.html?pub=6) Am Wed, 24 Jan 2007 17:41:11 -0500 schrieb George Hester: I would like to make a Sub that will return all the toolbars in Outlook currently displaying with VBA. The reason why I'd like to do this is because I have a COM called SpamBayes whose toolbar appears in the Outlook User Interface. The way this works is it inspects each New Mail and if it satisfies the criterion that the New Mail is spam it sends the e-mail to a folder called Junk E-Mail. I have set up some code so that the ItemAdd event for that folder will delete it entirely if the e-mail goes to that folder. Works well. But if some e-mail comes in that SpamBayes is unsure about the e-mail will go to a folder called Junk Suspects. Then in the toolbar provided by SpamBayes with the suspect e-mail selected, I can hit a buttom called Spam which sends the e-mail to the Junk E-Mail folder and the Bayesian criteria is satisfied. If it is not Spam I hit the button in the toolbar called Not Spam and the selected e-mail is put back in the Inbox. Both these buttons appear when the e-mail is in the Junk Suspects and is in that current folder but otherwise the button Spam always appears. What I would like to do is push the button Spam programatically that the selected e-mail (the item) is Junk E-Mail. It's ok this thing works pretty good so that 99% of all suspected e-mail is in fact Spam. But I think I need to know what the caption is for this toolbar. If I know that maybe I can hit the button programatically which will set the e-mail as spam and my other program will get rid of it. So is there a way to get a description (the caption) of each of the toolbars currently displaying in Outlook? Thanks. -- George Hester _________________________________ |
#3
|
|||
|
|||
Get a list of all the toolbars currently displaying in Outlook
Thanks Michael for the response. The toolbar appears in the Outlook main
window itself not in the toolbars that appear when an e-mail is opened. Will that make a difference? SpamBayes allows me to assign an e-mail is or is not Spam without even opening the e-mail itself. In fact what I have been doing is just looking at the Internet Headers to determine the Spamlihood of the e-mail. Sometines not even Internet Headers. Like for example if there is an attachment in the e-mail. Anything sent to me with an attachment that I have not arranged for is 99% likely Spam. I am familiar with what you provided I just can't seem to get a listing programitcally of the toolbars in the main Outlook window for that is where the SpamBayes toolbar is. -- George Hester _______________________________ "Michael Bauer [MVP - Outlook]" wrote in message ... Open one e-mail and look for the comandbars name. In code you can then access the bar with: Dim cb as Office.Commandbar set cb=Application.ActiveExplorer.Selection(1).Command bars("TheName") If the bar exists and is visible then get its button 1 or 2 and call its Execute method. -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook Keep your Outlook categories organized! http://www.shareit.com/product.html?...4&languageid=1 (German: http://www.VBOffice.net/product.html?pub=6) Am Wed, 24 Jan 2007 17:41:11 -0500 schrieb George Hester: I would like to make a Sub that will return all the toolbars in Outlook currently displaying with VBA. The reason why I'd like to do this is because I have a COM called SpamBayes whose toolbar appears in the Outlook User Interface. The way this works is it inspects each New Mail and if it satisfies the criterion that the New Mail is spam it sends the e-mail to a folder called Junk E-Mail. I have set up some code so that the ItemAdd event for that folder will delete it entirely if the e-mail goes to that folder. Works well. But if some e-mail comes in that SpamBayes is unsure about the e-mail will go to a folder called Junk Suspects. Then in the toolbar provided by SpamBayes with the suspect e-mail selected, I can hit a buttom called Spam which sends the e-mail to the Junk E-Mail folder and the Bayesian criteria is satisfied. If it is not Spam I hit the button in the toolbar called Not Spam and the selected e-mail is put back in the Inbox. Both these buttons appear when the e-mail is in the Junk Suspects and is in that current folder but otherwise the button Spam always appears. What I would like to do is push the button Spam programatically that the selected e-mail (the item) is Junk E-Mail. It's ok this thing works pretty good so that 99% of all suspected e-mail is in fact Spam. But I think I need to know what the caption is for this toolbar. If I know that maybe I can hit the button programatically which will set the as spam and my other program will get rid of it. So is there a way to get a description (the caption) of each of the toolbars currently displaying in Outlook? Thanks. -- George Hester _________________________________ |
#4
|
|||
|
|||
Get a list of all the toolbars currently displaying in Outlook
For the main window use the ActiveExplorer.Commandbars instead. -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook Keep your Outlook categories organized! http://www.shareit.com/product.html?...4&languageid=1 (German: http://www.VBOffice.net/product.html?pub=6) Am Thu, 25 Jan 2007 17:48:54 -0500 schrieb George Hester: Thanks Michael for the response. The toolbar appears in the Outlook main window itself not in the toolbars that appear when an e-mail is opened. Will that make a difference? SpamBayes allows me to assign an e-mail is or is not Spam without even opening the e-mail itself. In fact what I have been doing is just looking at the Internet Headers to determine the Spamlihood of the e-mail. Sometines not even Internet Headers. Like for example if there is an attachment in the e-mail. Anything sent to me with an attachment that I have not arranged for is 99% likely Spam. I am familiar with what you provided I just can't seem to get a listing programitcally of the toolbars in the main Outlook window for that is where the SpamBayes toolbar is. -- George Hester _______________________________ "Michael Bauer [MVP - Outlook]" wrote in message ... Open one e-mail and look for the comandbars name. In code you can then access the bar with: Dim cb as Office.Commandbar set cb=Application.ActiveExplorer.Selection(1).Command bars("TheName") If the bar exists and is visible then get its button 1 or 2 and call its Execute method. -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook Keep your Outlook categories organized! http://www.shareit.com/product.html?...4&languageid=1 (German: http://www.VBOffice.net/product.html?pub=6) Am Wed, 24 Jan 2007 17:41:11 -0500 schrieb George Hester: I would like to make a Sub that will return all the toolbars in Outlook currently displaying with VBA. The reason why I'd like to do this is because I have a COM called SpamBayes whose toolbar appears in the Outlook User Interface. The way this works is it inspects each New Mail and if it satisfies the criterion that the New Mail is spam it sends the e-mail to a folder called Junk E-Mail. I have set up some code so that the ItemAdd event for that folder will delete it entirely if the e-mail goes to that folder. Works well. But if some e-mail comes in that SpamBayes is unsure about the e-mail will go to a folder called Junk Suspects. Then in the toolbar provided by SpamBayes with the suspect e-mail selected, I can hit a buttom called Spam which sends the e-mail to the Junk E-Mail folder and the Bayesian criteria is satisfied. If it is not Spam I hit the button in the toolbar called Not Spam and the selected e-mail is put back in the Inbox. Both these buttons appear when the e-mail is in the Junk Suspects and is in that current folder but otherwise the button Spam always appears. What I would like to do is push the button Spam programatically that the selected e-mail (the item) is Junk E-Mail. It's ok this thing works pretty good so that 99% of all suspected e-mail is in fact Spam. But I think I need to know what the caption is for this toolbar. If I know that maybe I can hit the button programatically which will set the as spam and my other program will get rid of it. So is there a way to get a description (the caption) of each of the toolbars currently displaying in Outlook? Thanks. -- George Hester _________________________________ |
#5
|
|||
|
|||
Get a list of all the toolbars currently displaying in Outlook
On Wed, 24 Jan 2007 17:41:11 -0500, George Hester wrote in
microsoft.public.outlook.program_vba: I would like to make a Sub that will return all the toolbars in Outlook currently displaying with VBA. [snip] I had this lying around: Sub EnumerateControls() Dim myCB As CommandBar Dim myCtrl As CommandBarControl For Each myCB In ActiveExplorer.CommandBars Debug.Print "+++ CommandBar: " + myCB.Name + "+++" For Each myCtrl In myCB.Controls Debug.Print " --- Control: " + myCtrl.Caption + "---" Next myCtrl Next myCB Debug.Print "End of CommandBars and Controls for ActiveExplorer" For Each myCB In ActiveInspector.CommandBars Debug.Print "+++ CommandBar: " + myCB.Name + "+++" For Each myCtrl In myCB.Controls Debug.Print " --- Control: " + myCtrl.Caption + "---" Next myCtrl Next myCB Debug.Print "End of CommandBars and Controls for ActiveInspector" End Sub The second part obviously works only if you have an Inspector open. -- Michael Bednarek http://mbednarek.com/ "POST NO BILLS" |
#6
|
|||
|
|||
Get a list of all the toolbars currently displaying in Outlook
thanks again Michael. I found this page at Microsoft:
http://www.microsoft.com/technet/pro.../proddocs/opg/ part2/ch06.mspx this talks about the CommandBar near the middle in the function CBPrintCBarInfo. But it uses two functions not in the page; CBGetCBType and another CBGetCBCtlType. Maybe I am making this more complicated than it has to be but if you know these functions it would help me immensely if you could post them. Thanks. -- George Hester _________________________________ "Michael Bauer [MVP - Outlook]" wrote in message ... For the main window use the ActiveExplorer.Commandbars instead. -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook Keep your Outlook categories organized! http://www.shareit.com/product.html?...4&languageid=1 (German: http://www.VBOffice.net/product.html?pub=6) Am Thu, 25 Jan 2007 17:48:54 -0500 schrieb George Hester: Thanks Michael for the response. The toolbar appears in the Outlook main window itself not in the toolbars that appear when an e-mail is opened. Will that make a difference? SpamBayes allows me to assign an e-mail is or is not Spam without even opening the e-mail itself. In fact what I have been doing is just looking at the Internet Headers to determine the Spamlihood of the e-mail. Sometines not even Internet Headers. Like for example if there is an attachment in the e-mail. Anything sent to me with an attachment that I have not arranged for is 99% likely Spam. I am familiar with what you provided I just can't seem to get a listing programitcally of the toolbars in the main Outlook window for that is where the SpamBayes toolbar is. -- George Hester _______________________________ "Michael Bauer [MVP - Outlook]" wrote in message ... Open one e-mail and look for the comandbars name. In code you can then access the bar with: Dim cb as Office.Commandbar set cb=Application.ActiveExplorer.Selection(1).Command bars("TheName") If the bar exists and is visible then get its button 1 or 2 and call its Execute method. -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook Keep your Outlook categories organized! http://www.shareit.com/product.html?...4&languageid=1 (German: http://www.VBOffice.net/product.html?pub=6) Am Wed, 24 Jan 2007 17:41:11 -0500 schrieb George Hester: I would like to make a Sub that will return all the toolbars in Outlook currently displaying with VBA. The reason why I'd like to do this is because I have a COM called SpamBayes whose toolbar appears in the Outlook User Interface. The way this works is it inspects each New Mail and if it satisfies the criterion that the New Mail is spam it sends the e-mail to a folder called Junk E-Mail. I have set up some code so that the ItemAdd event for that folder will delete it entirely if the e-mail goes to that folder. Works well. But if some e-mail comes in that SpamBayes is unsure about the e-mail will go to a folder called Junk Suspects. Then in the toolbar provided by SpamBayes with the suspect e-mail selected, I can hit a buttom called Spam which sends the e-mail to the Junk E-Mail folder and the Bayesian criteria is satisfied. If it is not Spam I hit the button in the toolbar called Not Spam and the selected e-mail is put back in the Inbox. Both these buttons appear when the e-mail is in the Junk Suspects and is in that current folder but otherwise the button Spam always appears. What I would like to do is push the button Spam programatically that the selected e-mail (the item) is Junk E-Mail. It's ok this thing works pretty good so that 99% of all suspected e-mail is in fact Spam. But I think I need to know what the caption is for this toolbar. If I know that maybe I can hit the button programatically which will set the as spam and my other program will get rid of it. So is there a way to get a description (the caption) of each of the toolbars currently displaying in Outlook? Thanks. -- George Hester _________________________________ |
#7
|
|||
|
|||
Get a list of all the toolbars currently displaying in Outlook
I found them.
http://vba_consultant.blog.edoors.co...&articleId=252 5 http://vba_consultant.blog.edoors.co...&articleId=252 6 -- George Hester _________________________________ "George Hester" wrote in message ... thanks again Michael. I found this page at Microsoft: http://www.microsoft.com/technet/pro.../proddocs/opg/ part2/ch06.mspx this talks about the CommandBar near the middle in the function CBPrintCBarInfo. But it uses two functions not in the page; CBGetCBType and another CBGetCBCtlType. Maybe I am making this more complicated than it has to be but if you know these functions it would help me immensely if you could post them. Thanks. -- George Hester _________________________________ "Michael Bauer [MVP - Outlook]" wrote in message ... For the main window use the ActiveExplorer.Commandbars instead. -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook Keep your Outlook categories organized! http://www.shareit.com/product.html?...4&languageid=1 (German: http://www.VBOffice.net/product.html?pub=6) Am Thu, 25 Jan 2007 17:48:54 -0500 schrieb George Hester: Thanks Michael for the response. The toolbar appears in the Outlook main window itself not in the toolbars that appear when an e-mail is opened. Will that make a difference? SpamBayes allows me to assign an e-mail is or is not Spam without even opening the e-mail itself. In fact what I have been doing is just looking at the Internet Headers to determine the Spamlihood of the e-mail. Sometines not even Internet Headers. Like for example if there is an attachment in the e-mail. Anything sent to me with an attachment that I have not arranged for is 99% likely Spam. I am familiar with what you provided I just can't seem to get a listing programitcally of the toolbars in the main Outlook window for that is where the SpamBayes toolbar is. -- George Hester _______________________________ "Michael Bauer [MVP - Outlook]" wrote in message ... Open one e-mail and look for the comandbars name. In code you can then access the bar with: Dim cb as Office.Commandbar set cb=Application.ActiveExplorer.Selection(1).Command bars("TheName") If the bar exists and is visible then get its button 1 or 2 and call its Execute method. -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook Keep your Outlook categories organized! http://www.shareit.com/product.html?...4&languageid=1 (German: http://www.VBOffice.net/product.html?pub=6) Am Wed, 24 Jan 2007 17:41:11 -0500 schrieb George Hester: I would like to make a Sub that will return all the toolbars in Outlook currently displaying with VBA. The reason why I'd like to do this is because I have a COM called SpamBayes whose toolbar appears in the Outlook User Interface. The way this works is it inspects each New Mail and if it satisfies the criterion that the New Mail is spam it sends the to a folder called Junk E-Mail. I have set up some code so that the ItemAdd event for that folder will delete it entirely if the e-mail goes to that folder. Works well. But if some e-mail comes in that SpamBayes is unsure about the will go to a folder called Junk Suspects. Then in the toolbar provided by SpamBayes with the suspect e-mail selected, I can hit a buttom called Spam which sends the e-mail to the Junk E-Mail folder and the Bayesian criteria is satisfied. If it is not Spam I hit the button in the toolbar called Not Spam and the selected e-mail is put back in the Inbox. Both these buttons appear when the e-mail is in the Junk Suspects and is in that current folder but otherwise the button Spam always appears. What I would like to do is push the button Spam programatically that the selected e-mail (the item) is Junk E-Mail. It's ok this thing works pretty good so that 99% of all suspected e-mail is in fact Spam. But I think I need to know what the caption is for this toolbar. If I know that maybe I can hit the button programatically which will set the as spam and my other program will get rid of it. So is there a way to get a description (the caption) of each of the toolbars currently displaying in Outlook? Thanks. -- George Hester _________________________________ |
#8
|
|||
|
|||
Get a list of all the toolbars currently displaying in Outlook
Yes, you make it much to complicated :-) You could also right click on the toolbar and see the bars' names, they won't change. Then use the code I've provided, either with ActiveExplorer.Commandbars or ActiveInspector.Commandbars. -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook Keep your Outlook categories organized! http://www.shareit.com/product.html?...4&languageid=1 (German: http://www.VBOffice.net/product.html?pub=6) Am Sat, 27 Jan 2007 14:10:56 -0500 schrieb George Hester: thanks again Michael. I found this page at Microsoft: http://www.microsoft.com/technet/pro.../proddocs/opg/ part2/ch06.mspx this talks about the CommandBar near the middle in the function CBPrintCBarInfo. But it uses two functions not in the page; CBGetCBType and another CBGetCBCtlType. Maybe I am making this more complicated than it has to be but if you know these functions it would help me immensely if you could post them. Thanks. -- George Hester _________________________________ "Michael Bauer [MVP - Outlook]" wrote in message ... For the main window use the ActiveExplorer.Commandbars instead. -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook Keep your Outlook categories organized! http://www.shareit.com/product.html?...4&languageid=1 (German: http://www.VBOffice.net/product.html?pub=6) Am Thu, 25 Jan 2007 17:48:54 -0500 schrieb George Hester: Thanks Michael for the response. The toolbar appears in the Outlook main window itself not in the toolbars that appear when an e-mail is opened. Will that make a difference? SpamBayes allows me to assign an e-mail is or is not Spam without even opening the e-mail itself. In fact what I have been doing is just looking at the Internet Headers to determine the Spamlihood of the e-mail. Sometines not even Internet Headers. Like for example if there is an attachment in the e-mail. Anything sent to me with an attachment that I have not arranged for is 99% likely Spam. I am familiar with what you provided I just can't seem to get a listing programitcally of the toolbars in the main Outlook window for that is where the SpamBayes toolbar is. -- George Hester _______________________________ "Michael Bauer [MVP - Outlook]" wrote in message ... Open one e-mail and look for the comandbars name. In code you can then access the bar with: Dim cb as Office.Commandbar set cb=Application.ActiveExplorer.Selection(1).Command bars("TheName") If the bar exists and is visible then get its button 1 or 2 and call its Execute method. -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook Keep your Outlook categories organized! http://www.shareit.com/product.html?...4&languageid=1 (German: http://www.VBOffice.net/product.html?pub=6) Am Wed, 24 Jan 2007 17:41:11 -0500 schrieb George Hester: I would like to make a Sub that will return all the toolbars in Outlook currently displaying with VBA. The reason why I'd like to do this is because I have a COM called SpamBayes whose toolbar appears in the Outlook User Interface. The way this works is it inspects each New Mail and if it satisfies the criterion that the New Mail is spam it sends the e-mail to a folder called Junk E-Mail. I have set up some code so that the ItemAdd event for that folder will delete it entirely if the e-mail goes to that folder. Works well. But if some e-mail comes in that SpamBayes is unsure about the e-mail will go to a folder called Junk Suspects. Then in the toolbar provided by SpamBayes with the suspect e-mail selected, I can hit a buttom called Spam which sends the e-mail to the Junk E-Mail folder and the Bayesian criteria is satisfied. If it is not Spam I hit the button in the toolbar called Not Spam and the selected e-mail is put back in the Inbox. Both these buttons appear when the e-mail is in the Junk Suspects and is in that current folder but otherwise the button Spam always appears. What I would like to do is push the button Spam programatically that the selected e-mail (the item) is Junk E-Mail. It's ok this thing works pretty good so that 99% of all suspected e-mail is in fact Spam. But I think I need to know what the caption is for this toolbar. If I know that maybe I can hit the button programatically which will set the as spam and my other program will get rid of it. So is there a way to get a description (the caption) of each of the toolbars currently displaying in Outlook? Thanks. -- George Hester _________________________________ |
#9
|
|||
|
|||
Get a list of all the toolbars currently displaying in Outlook
yes I got it all going. Actually the typing helped me to identify the
buttons Popup and such. It is always a good idea to know the names of the things we are working with. Anyway I have run into a snag. The first time I tried it I got a messige "No filterd item was selected." What this means is although I am using the ItemAdd event in the folder Junk Suspects and you would think the argument of the ItemAdd event which is Item As Object you would think that implies the item is Selected. But no. So I did fix that but this is what happened. I move the spam from the more_spam folder to Junk Suspects to initiate the Item_Add event for JunkSuspects. Then I use the Selection Collection to select that added MailItem in Jiunk Suspects. But when I do that remember I am still in the folder more_spam. When I move a MailItem out of there the next message in that folder gets selected for moving. Hence it doesn't work right. This is what happens\. The message I move to Junk Suspects stays in the folder Junk Suspects and the message in more_spam that is selected by default gets selected and moved to Junk E-Mail. Remember I do not want to open these e-mails at all. So now I am stuck selecting two messages at once and I fon't want that. Here is the sub: Option Explicit Public Const ERR_INVALID_CMDBARNAME As Long = &H5 Public Sub CBPrintCBarInfo(strCBarName As String) On Error GoTo CBPrintCBarInfo_Err Dim oOLApp As Outlook.Application Dim oeExplorer As Outlook.Explorer Dim oscSelection As Outlook.Selection Dim cbrBar As Office.CommandBar Dim ctlCBarControl As Office.CommandBarControl Dim oMS1 As Outlook.MailItem Dim iFor As Integer Set oOLApp = CreateObject("Outlook.Application") Set oeExplorer = oOLApp.ActiveExplorer Set oscSelection = oeExplorer.Selection Set cbrBar = oeExplorer.CommandBars(strCBarName) For iFor = 1 To oscSelection.Count 'I think the problem is here and 2 lines below it. 'If I use 1 here then I have no control over what gets selected first If oscSelection.Item(iFor).Class = olMail Then Set oMS1 = oscSelection.Item(iFor) For Each ctlCBarControl In cbrBar.Controls If ctlCBarControl.Caption = "Spam" Then ctlCBarControl.Execute End If Next ctlCBarControl End If Next iFor CBPrintCBarInfo_End: Set cbrBar = Nothing Set oMS1 = Nothing Set oscSelection = Nothing Set oeExplorer = Nothing Set oOLApp = Nothing Exit Sub CBPrintCBarInfo_Err: Select Case Err.Number Case ERR_INVALID_CMDBARNAME MsgBox "'" & strCBarName & _ "' is not a valid commad bar name!" Case Else MsgBox "Error: " & Err.Number _ & " - " & Err.Description End Select Err.Clear Resume CBPrintCBarInfo_End End Sub As I was typing this I tried to use EntryID of the mail that was moved but it seems that when it is selected it gets changed. -- George Hester _________________________________ "Michael Bauer [MVP - Outlook]" wrote in message ... Yes, you make it much to complicated :-) You could also right click on the toolbar and see the bars' names, they won't change. Then use the code I've provided, either with ActiveExplorer.Commandbars or ActiveInspector.Commandbars. -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook Keep your Outlook categories organized! http://www.shareit.com/product.html?...4&languageid=1 (German: http://www.VBOffice.net/product.html?pub=6) Am Sat, 27 Jan 2007 14:10:56 -0500 schrieb George Hester: thanks again Michael. I found this page at Microsoft: http://www.microsoft.com/technet/pro.../proddocs/opg/ part2/ch06.mspx this talks about the CommandBar near the middle in the function CBPrintCBarInfo. But it uses two functions not in the page; CBGetCBType and another CBGetCBCtlType. Maybe I am making this more complicated than it has to be but if you know these functions it would help me immensely if you could post them. Thanks. -- George Hester _________________________________ "Michael Bauer [MVP - Outlook]" wrote in message ... For the main window use the ActiveExplorer.Commandbars instead. -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook Keep your Outlook categories organized! http://www.shareit.com/product.html?...4&languageid=1 (German: http://www.VBOffice.net/product.html?pub=6) Am Thu, 25 Jan 2007 17:48:54 -0500 schrieb George Hester: Thanks Michael for the response. The toolbar appears in the Outlook main window itself not in the toolbars that appear when an e-mail is opened. Will that make a difference? SpamBayes allows me to assign an e-mail is or is not Spam without even opening the e-mail itself. In fact what I have been doing is just looking at the Internet Headers to determine the Spamlihood of the e-mail. Sometines not even Internet Headers. Like for example if there is an attachment in the e-mail. Anything sent to me with an attachment that I have not arranged for is 99% likely Spam. I am familiar with what you provided I just can't seem to get a listing programitcally of the toolbars in the main Outlook window for that is where the SpamBayes toolbar is. -- George Hester _______________________________ "Michael Bauer [MVP - Outlook]" wrote in message ... Open one e-mail and look for the comandbars name. In code you can then access the bar with: Dim cb as Office.Commandbar set cb=Application.ActiveExplorer.Selection(1).Command bars("TheName") If the bar exists and is visible then get its button 1 or 2 and call its Execute method. -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook Keep your Outlook categories organized! http://www.shareit.com/product.html?...4&languageid=1 (German: http://www.VBOffice.net/product.html?pub=6) Am Wed, 24 Jan 2007 17:41:11 -0500 schrieb George Hester: I would like to make a Sub that will return all the toolbars in Outlook currently displaying with VBA. The reason why I'd like to do this is because I have a COM called SpamBayes whose toolbar appears in the Outlook User Interface. The way this works is it inspects each New Mail and if it satisfies the criterion that the New Mail is spam it sends the to a folder called Junk E-Mail. I have set up some code so that the ItemAdd event for that folder will delete it entirely if the e-mail goes to that folder. Works well. But if some e-mail comes in that SpamBayes is unsure about the will go to a folder called Junk Suspects. Then in the toolbar provided by SpamBayes with the suspect e-mail selected, I can hit a buttom called Spam which sends the e-mail to the Junk E-Mail folder and the Bayesian criteria is satisfied. If it is not Spam I hit the button in the toolbar called Not Spam and the selected e-mail is put back in the Inbox. Both these buttons appear when the e-mail is in the Junk Suspects and is in that current folder but otherwise the button Spam always appears. What I would like to do is push the button Spam programatically that the selected e-mail (the item) is Junk E-Mail. It's ok this thing works pretty good so that 99% of all suspected e-mail is in fact Spam. But I think I need to know what the caption is for this toolbar. If I know that maybe I can hit the button programatically which will set the as spam and my other program will get rid of it. So is there a way to get a description (the caption) of each of the toolbars currently displaying in Outlook? Thanks. -- George Hester _________________________________ |
#10
|
|||
|
|||
Get a list of all the toolbars currently displaying in Outlook
ok I got it I think. I wasn't using the Explorer object corrrectly. Here
is the New and Improved version: Option Explicit Public Const ERR_INVALID_CMDBARNAME As Long = &H5 Public Sub CBPrintCBarInfo(oFld As MAPIFolder, oMS As MailItem, strCBarName As String) On Error GoTo CBPrintCBarInfo_Err Dim oOLApp As Outlook.Application Dim oeExplorer As Outlook.Explorer Dim oscSelection As Outlook.Selection Dim cbrBar As Office.CommandBar Dim ctlCBarControl As Office.CommandBarControl Dim oMS1 As Outlook.MailItem Dim sEntID As String Dim iFor As Integer sEntID = oMS.EntryID Set oOLApp = CreateObject("Outlook.Application") Set oeExplorer = oFld.GetExplorer(olFolderDisplayNoNavigation) Set oscSelection = oeExplorer.Selection Set cbrBar = oeExplorer.CommandBars(strCBarName) For iFor = 1 To oscSelection.Count If oscSelection.Item(iFor).Class = olMail Then Set oMS1 = oscSelection.Item(iFor) If oMS1.EntryID = sEntID Then For Each ctlCBarControl In cbrBar.Controls If ctlCBarControl.Caption = "Spam" Then ctlCBarControl.Execute End If Next ctlCBarControl End If End If Next iFor CBPrintCBarInfo_End: Set cbrBar = Nothing Set oMS1 = Nothing Set oscSelection = Nothing Set oeExplorer = Nothing Set oOLApp = Nothing Exit Sub CBPrintCBarInfo_Err: Select Case Err.Number Case ERR_INVALID_CMDBARNAME MsgBox "'" & strCBarName & _ "' is not a valid commad bar name!" Case Else MsgBox "Error: " & Err.Number _ & " - " & Err.Description End Select Err.Clear Resume CBPrintCBarInfo_End End Sub -- George Hester _________________________________ "Michael Bauer [MVP - Outlook]" wrote in message ... Yes, you make it much to complicated :-) You could also right click on the toolbar and see the bars' names, they won't change. Then use the code I've provided, either with ActiveExplorer.Commandbars or ActiveInspector.Commandbars. -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook Keep your Outlook categories organized! http://www.shareit.com/product.html?...4&languageid=1 (German: http://www.VBOffice.net/product.html?pub=6) Am Sat, 27 Jan 2007 14:10:56 -0500 schrieb George Hester: thanks again Michael. I found this page at Microsoft: http://www.microsoft.com/technet/pro.../proddocs/opg/ part2/ch06.mspx this talks about the CommandBar near the middle in the function CBPrintCBarInfo. But it uses two functions not in the page; CBGetCBType and another CBGetCBCtlType. Maybe I am making this more complicated than it has to be but if you know these functions it would help me immensely if you could post them. Thanks. -- George Hester _________________________________ "Michael Bauer [MVP - Outlook]" wrote in message ... For the main window use the ActiveExplorer.Commandbars instead. -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook Keep your Outlook categories organized! http://www.shareit.com/product.html?...4&languageid=1 (German: http://www.VBOffice.net/product.html?pub=6) Am Thu, 25 Jan 2007 17:48:54 -0500 schrieb George Hester: Thanks Michael for the response. The toolbar appears in the Outlook main window itself not in the toolbars that appear when an e-mail is opened. Will that make a difference? SpamBayes allows me to assign an e-mail is or is not Spam without even opening the e-mail itself. In fact what I have been doing is just looking at the Internet Headers to determine the Spamlihood of the e-mail. Sometines not even Internet Headers. Like for example if there is an attachment in the e-mail. Anything sent to me with an attachment that I have not arranged for is 99% likely Spam. I am familiar with what you provided I just can't seem to get a listing programitcally of the toolbars in the main Outlook window for that is where the SpamBayes toolbar is. -- George Hester _______________________________ "Michael Bauer [MVP - Outlook]" wrote in message ... Open one e-mail and look for the comandbars name. In code you can then access the bar with: Dim cb as Office.Commandbar set cb=Application.ActiveExplorer.Selection(1).Command bars("TheName") If the bar exists and is visible then get its button 1 or 2 and call its Execute method. -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook Keep your Outlook categories organized! http://www.shareit.com/product.html?...4&languageid=1 (German: http://www.VBOffice.net/product.html?pub=6) Am Wed, 24 Jan 2007 17:41:11 -0500 schrieb George Hester: I would like to make a Sub that will return all the toolbars in Outlook currently displaying with VBA. The reason why I'd like to do this is because I have a COM called SpamBayes whose toolbar appears in the Outlook User Interface. The way this works is it inspects each New Mail and if it satisfies the criterion that the New Mail is spam it sends the to a folder called Junk E-Mail. I have set up some code so that the ItemAdd event for that folder will delete it entirely if the e-mail goes to that folder. Works well. But if some e-mail comes in that SpamBayes is unsure about the will go to a folder called Junk Suspects. Then in the toolbar provided by SpamBayes with the suspect e-mail selected, I can hit a buttom called Spam which sends the e-mail to the Junk E-Mail folder and the Bayesian criteria is satisfied. If it is not Spam I hit the button in the toolbar called Not Spam and the selected e-mail is put back in the Inbox. Both these buttons appear when the e-mail is in the Junk Suspects and is in that current folder but otherwise the button Spam always appears. What I would like to do is push the button Spam programatically that the selected e-mail (the item) is Junk E-Mail. It's ok this thing works pretty good so that 99% of all suspected e-mail is in fact Spam. But I think I need to know what the caption is for this toolbar. If I know that maybe I can hit the button programatically which will set the as spam and my other program will get rid of it. So is there a way to get a description (the caption) of each of the toolbars currently displaying in Outlook? Thanks. -- George Hester _________________________________ |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
list of available toolbars | Marcin Junger | Add-ins for Outlook | 1 | September 28th 06 12:53 PM |
Toolbars in messages, Outlook 2003 | [email protected] | Outlook - General Queries | 2 | July 12th 06 08:25 PM |
Toolbars in Outlook 2007 | JimD | Outlook - Installation | 1 | June 18th 06 03:52 AM |
MS Outlook 2003 toolbars will keep still | nothing | Outlook - General Queries | 1 | May 31st 06 04:35 AM |
Toolbars at Outlook Start Up | Toolbars at Outlook Start Up | Outlook - Installation | 3 | May 19th 06 03:06 PM |