Results 1 to 19 of 19

Thread: Command Bar

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2005
    Posts
    151

    Command Bar

    When i am recalling a message in outlook, I get a lebel somthing like this in the sentmessage:

    You attempted to recall this message on Monday, November 21, 2005 10:19 AM.

    I want to take out this timing when the message was recalled.


    Actually, I have written a script which recalls a message.
    What i am doing is i am displaying the message and then clicking recal message button through my script. After this dialog box appears :

    delete unread copies of this message..
    ...........

    If i click ok then control comes back to my script and messagebox displays message has been recalled.
    But, if user clicks cancel then also my code displays message box message has been recalled. Because i cant check which button is clicked?

    So, after clicking any of the button on the dialog box i will check what is the recalled time of the message and if it matches with the system time then the message is recalled, otherwise if time dosn't match then message is not recalled.

    So, can anyone has the method using which i can get the recall time of the message......

    Thanks...
    Last edited by v_gyku; Nov 21st, 2005 at 12:08 AM.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Command Bar

    How come you cant check which button was pressed?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2005
    Posts
    151

    Re: Command Bar

    How will i come to know programatically which button was clicked?

    If i can know which button is clicked then my probem is solved....

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Command Bar

    Aren't you executing the button to display the message?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Sep 2005
    Posts
    151

    Re: Command Bar

    Code:
    If Mid(outlook.Version, 1, 2) = "10" Then
                   item1.Display
                   Set pop = ActiveInspector.CommandBars(3).Controls(7)
                   pop.Controls(13).Execute
                   ActiveInspector.Close olDiscard
                   item1.Close olDiscard
    end if
    MsgBox "The selected e-mail(s) have been recalled.
    I have written this code....
    This displays the message and from that message clicks recall this message button, after this dialog box appears, after clicking any button it will do the functionality properly..(depends on which button is clicked). But if user has clicked cancel, still i am displaying message 'message has been recalled'.

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Command Bar

    .Execute returns an Action item. You should be able to retrieve the Action item for the Recall and perhaps from there you can determine the response.
    VB Code:
    1. Dim myReply As Outlook.Action
    2. Set myReply = myItem.Actions("Reply").Execute
    3. myReply.Send
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Sep 2005
    Posts
    151

    Re: Command Bar

    sorry sir, but i didn't get you?

    I will explain u my problem once again...

    I am executing "recall this message" button

    After this dialog appears if user clicks cancel or any button control comes back to my code and displays messagebox as given in above code.

    So i think if i can check the recall time of the message and if it matches with the system time then i can determine ok was clicked or cancel as clicked.

    If ok is clicked then i wil get the following thing:

    You attempted to recall this message on Monday, November 21, 2005 10:19 AM.

    If this timing matches the system time then i can determine ok was clicked or else cancel was clicked...

    Thanks...

  8. #8
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Command Bar

    You can trap the button that was returned. It should work the same in VBA

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4.   Dim m As Long
    5.   m = MsgBox("Enter YES or NO", vbYesNo)
    6.   If m = vbYes Then
    7.     MsgBox "Yes was selected"
    8.   End If
    9. End Sub

  9. #9
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Command Bar

    Its not that kind of object. Its an Office.CommandBarButton object that displays a secondary message. If the .execute prompts this dialog then it still should have that info in the returning Action object.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Sep 2005
    Posts
    151

    Re: Command Bar

    Hi all...

    I have attached the outlook screen shot with this post.

    Can i get the timing of recall? so that i can compare it with system time...
    Attached Images Attached Images  

  11. #11
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Command Bar

    I think you may be making this more complicated then it has to be. If you get the returned Outlook Item boject you can access its properties to read the date/time.

    Execute: Returns the Microsoft Outlook item created by the action.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Sep 2005
    Posts
    151

    Re: Command Bar

    sorry but i am not able to understand what are u trying to tell me and how it is going to help me.

    Sir can u give me any example plz...

  13. #13
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Command Bar

    Code example in post #6. If you take the returned item you can check the date/time the message was attemped to be recalled. If you get an item returned and its valid then the user must have clicked yes/ok. Then look at the items properties to see what you need.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  14. #14

    Thread Starter
    Addicted Member
    Join Date
    Sep 2005
    Posts
    151

    Re: Command Bar

    Code:
    Sub fddfg()
        Dim pop As CommandBarPopup
        Dim mailib As MAPIFolder
        Dim myitem As Outlook.MailItem
        Dim co As CommandBar
        Set mailib = Application.GetNamespace("mapi").GetDefaultFolder(olFolderSentMail)
        Set myitem = mailib.Items.Item(1)
    
    'Set co = myitem.GetInspector.CommandBars(4)
    'MsgBox co.Name
    'Dim myReply As Outlook.Action
    'Dim str As String
    'Set pop = myitem.GetInspector.CommandBars(4).Controls(7)
    'str = pop.Controls(11).Caption
    'myitem.Display
    'Set myReply = myitem.Actions(pop.Controls(11).Caption).Execute
    'myReply.Send
    'End Sub
    
    Dim myReply As Outlook.Action
    Set myReply = myitem.Actions("Reply").Execute
    myReply.Send
    End Sub
    Its giving me error type missed match on this line:
    Code:
    Set myReply = myitem.Actions("Reply").Execute

  15. #15
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Command Bar

    That was just the example code not relevant to yours. Try this on its own to see how you can retrieve the reply mailitem object instance.
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4.  
    5.     Dim myOlApp As Outlook.Application
    6.     Dim myItem As Outlook.MailItem
    7.     Dim myReply As Outlook.MailItem
    8.    
    9.     Set myOlApp = New Outlook.Application
    10.     Set myItem = myOlApp.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Items.Item(1)
    11.     Set myReply = myItem.Actions("Reply").Execute
    12.     myReply.Display
    13.    
    14. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  16. #16

    Thread Starter
    Addicted Member
    Join Date
    Sep 2005
    Posts
    151

    Re: Command Bar

    Code:
    Dim myOlApp As Outlook.Application
        Dim myItem As Outlook.MailItem
        Dim myReply As Outlook.MailItem
        Dim pop As CommandBarPopup
        Set myOlApp = New Outlook.Application
        Set myItem = myOlApp.GetNamespace("MAPI").GetDefaultFolder(olFolderSentMail).Items.Item(1)
        Set myReply = myItem.Actions("Recall This Message").Execute
        
    End Sub
    if i put 'Forward' or 'Reply' or 'Reply to All' in above example it works.
    But if i put 'Recall This Message' i get following error message:
    Object variable or with block varibale not set...

  17. #17
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Command Bar

    Check if there is a menu accelerator key in the caption. If so you need to add the "&" before that character.

    Just checked and it should be "Recall &This Message..."
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  18. #18

    Thread Starter
    Addicted Member
    Join Date
    Sep 2005
    Posts
    151

    Re: Command Bar

    For all items there is a menu acceleration key in caption
    eg:- &Reply
    If i use &Reply code dosn't work....gives error-- object variable or with block variable not set.(Its working with 'Reply')

    In case of Recall This message code dosn't work either with 'Recall This Message' or 'Recall &This Message'.

  19. #19

    Thread Starter
    Addicted Member
    Join Date
    Sep 2005
    Posts
    151

    Re: Command Bar

    I have attached a project with this post.

    If the user clicks cancel button in the dialog box, different messagebox should be displayed(eg. Message canot be reclled.)

    As i have mentioned in above posts one way would be.....

    Compare the system time with recalled time(recalled time is displayed in a lebel kind of thing) i have given screen shot in the earlier post.If both timings matches then message is recalled(i.e. ok is clicked).If timings dosn't match then message is not recalled(i.e. User has clicked cancel).....

    I want to know how can i het the recaling time of the message.

    Thanks...
    Attached Files Attached Files
    Last edited by v_gyku; Nov 22nd, 2005 at 01:42 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width