![]() |
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
|
|||
|
|||
![]()
I am trying to add a button to the menu bar after opening an email
with varying results. I use the code; Private Sub oOpenMail_Open(Cancel As Boolean) 'Event gets triggered if oOpenMail is opened! Dim oMailBar As Office.CommandBar 'Set a reference to commandbar Standard and add the commandbutton Set oMailBar = oMailInspector.CommandBars("Menu Bar") 'Clean up left over buttons if any Call DeleteButtons(oMailBar) 'set oMailTagsButton Set oMSubjectButton = oMailBar.Controls.Add(Type:=msoControlButton) oMailBar.Visible = True 'Set properties of "Msubject" button With oMSubjectButton .Caption = "MSubject" On Error Resume Next .Picture = LoadPicture(root & "spidey.bmp") On Error GoTo 0 .Style = msoButtonIconAndCaption End With 'Clean up Set oMailBar = Nothing End Sub Email is either in rich text or html format there are either 8 or 9 items on the menu bar before I add my button. The icon is sometimes displayed with caption and sometimes the caption by itself. The module behind the button is sometimes triggered and aassumes foreground and sometimes triggered and remains behind other windows. Sometimes no action is triggered or at least the form which is the action does not show up. Why so many behaviors for a message? All suggestions/comments welcomed. Thanks |
#2
|
|||
|
|||
![]()
For one thing, the event to use to create toolbar UI is
Inspector.Activate(), not item.Open(). For a second thing, you cannot use button.Picture or button.Mask for WordMail 2003 or earlier versions of WordMail. If any of the items are WordMail items you must use the button.PasteFace() method of putting the image on the clipboard instead of using Picture or Mask. Both Picture and Mask take an IPictureDisp object. IPictureDisp objects cannot be passed across process boundaries. In the case of the Outlook editor a COM addin will be running in-process with Outlook so you can use Picture and Mask. If WordMail is being used the editor is a subclassing of word.exe and runs out of process with Outlook, therefore attempts to pass an IPictureDisp object will fire an exception. -- 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 wrote in message ... I am trying to add a button to the menu bar after opening an email with varying results. I use the code; Private Sub oOpenMail_Open(Cancel As Boolean) 'Event gets triggered if oOpenMail is opened! Dim oMailBar As Office.CommandBar 'Set a reference to commandbar Standard and add the commandbutton Set oMailBar = oMailInspector.CommandBars("Menu Bar") 'Clean up left over buttons if any Call DeleteButtons(oMailBar) 'set oMailTagsButton Set oMSubjectButton = oMailBar.Controls.Add(Type:=msoControlButton) oMailBar.Visible = True 'Set properties of "Msubject" button With oMSubjectButton .Caption = "MSubject" On Error Resume Next .Picture = LoadPicture(root & "spidey.bmp") On Error GoTo 0 .Style = msoButtonIconAndCaption End With 'Clean up Set oMailBar = Nothing End Sub Email is either in rich text or html format there are either 8 or 9 items on the menu bar before I add my button. The icon is sometimes displayed with caption and sometimes the caption by itself. The module behind the button is sometimes triggered and aassumes foreground and sometimes triggered and remains behind other windows. Sometimes no action is triggered or at least the form which is the action does not show up. Why so many behaviors for a message? All suggestions/comments welcomed. Thanks |
#3
|
|||
|
|||
![]()
re activate vs open - I am triggering the procedure with the following
code; Private Sub oAppInspectors_NewInspector(ByVal Inspector As Inspector) 'Event gets triggered every time a Window or Item is opened in Outlook Interface 'Like: E-mail, Contacts, Tasks .... ElseIf Inspector.CurrentItem.Class = 43 Then 'Deal with Mail Items...else exit 'Set a reference to the e-mail to trap the Open event Set oOpenMail = Inspector.CurrentItem Set oMailInspector = Inspector 'MsgBox "new mail inspector" Do you mean that I should create a procedure; Private Sub oOpenMail_Activate(Cancel As Boolean) 'Event gets triggered if oOpenMail is opened! PasteFace The CopyBitmapAsButtonFace function is not defined - do you know what the library name is so I can reference it? Thanks |
#4
|
|||
|
|||
![]()
In Outlook 2007 and generally with WordMail you only get a weak object
reference for the Inspector passed to you in the NewInspector() event handler. That means that all properties may not reliably be there. In general you should only use the .Class or .EntryID or .MessageClass properties from Inspector.CurrentItem in that event handler. When Inspector.Activate() fires is when you should be creating UI for your Inspector. There are lots of examples of Inspector wrappers and event handlers on the Web, depending on what version of Outlook you are programming for you can find examples for that version. CopyBitmapAsButtonFace is not a library function that you can reference, it's a function that has to be developed using Win32 API calls or copied from an example of the function. -- 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 wrote in message ... re activate vs open - I am triggering the procedure with the following code; Private Sub oAppInspectors_NewInspector(ByVal Inspector As Inspector) 'Event gets triggered every time a Window or Item is opened in Outlook Interface 'Like: E-mail, Contacts, Tasks ... ElseIf Inspector.CurrentItem.Class = 43 Then 'Deal with Mail Items...else exit 'Set a reference to the e-mail to trap the Open event Set oOpenMail = Inspector.CurrentItem Set oMailInspector = Inspector 'MsgBox "new mail inspector" Do you mean that I should create a procedure; Private Sub oOpenMail_Activate(Cancel As Boolean) 'Event gets triggered if oOpenMail is opened! PasteFace The CopyBitmapAsButtonFace function is not defined - do you know what the library name is so I can reference it? Thanks |
#5
|
|||
|
|||
![]()
Ken,
You are advising me to set up my UI through the use of the inspector.activate (event?) The defn below suggests that this would be triggered in the course of executing a main program rather than through an "external" event (newinspector) Inspector.Activate Method Outlook Developer Reference Activates an inspector window by bringing it to the foreground and setting keyboard focus. The source of my example is; http://www.vbaexpress.com/kb/getarticle.php?kb_id=502 I just want to change the UI on opening a mail or appointment item. Is there a way of doing this. Is there some code I can crib from? Thanks |
#6
|
|||
|
|||
![]()
No, not the Activate() method, the Activate event.
I don't know if you're using VB or VBA but there are examples of Inspector handling as I mentioned, Just do a Google search on "Inspector wrapper". The example you mention doesn't use the Inspector events instantiated from Inspectors.NewInspector(), it uses item events. I'm suggesting using something like this, leaving aside the notion of handling multiple open Inspectors which is what an Inspector wrapper is used for: Private Sub oAppInspectors_NewInspector(ByVal Inspector As Inspector) 'Event gets triggered every time a Window or Item is opened in Outlook Interface 'Like: E-mail, Contacts, Tasks If Inspector.CurrentItem.Class olMail Then 'Only deal with Email Items...else exit Exit Sub End If Set oMailInspector = Inspector End Sub Private Sub oMailInspector_Activate() ' UI creation here End Sub -- 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 wrote in message ... Ken, You are advising me to set up my UI through the use of the inspector.activate (event?) The defn below suggests that this would be triggered in the course of executing a main program rather than through an "external" event (newinspector) Inspector.Activate Method Outlook Developer Reference Activates an inspector window by bringing it to the foreground and setting keyboard focus. The source of my example is; http://www.vbaexpress.com/kb/getarticle.php?kb_id=502 I just want to change the UI on opening a mail or appointment item. Is there a way of doing this. Is there some code I can crib from? Thanks |
#7
|
|||
|
|||
![]()
Regarding CopyBitmapAsButtonFace, I found what you are referring to -
three hundred lines of German - I'll try it later. Thanks http://support.microsoft.com/kb/288771/nl |
#8
|
|||
|
|||
![]() That's dutch. Anyway, at the upper right corner is a combox where you can choose your preferred language. -- Best regards Michael Bauer - MVP Outlook Use Outlook Categories? This is Your Tool: http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6 Am Thu, 6 Mar 2008 21:15:21 -0800 (PST) schrieb : Regarding CopyBitmapAsButtonFace, I found what you are referring to - three hundred lines of German - I'll try it later. Thanks http://support.microsoft.com/kb/288771/nl |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Can I format phone numbers differently? | DL in Seattle | Outlook - Using Contacts | 1 | January 25th 08 11:57 PM |
Contacts Display Differently | TJAC | Outlook - Using Contacts | 9 | February 19th 07 06:53 PM |
Test email works but cannot send actual emails | Nicky | Outlook - Installation | 3 | January 11th 07 05:07 PM |
Configuring a default option differently | mkellen494 | Outlook - Installation | 0 | October 10th 06 09:39 PM |
cannot receive or send emails but 'test account settings' works | Cannot send receive emails in Outlook 20 | Outlook - Installation | 3 | August 12th 06 05:19 PM |