Page 1 of 2 12 LastLast
Results 1 to 40 of 57

Thread: Outlook Mailmerge using VBA

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2004
    Posts
    22

    Outlook Mailmerge using VBA

    Hi

    I have tried posting this at various other outlook forums, but never had a single reply (maybe that says more about my Q than the people in the forums.

    I am trying to produce a macro with VBA in Outlook (to assign to an outlook toolbar) to do the following: -

    when outlook is in the contacts view, to mailmerge the highlighted
    contact only, with a known word mailmerge document. At the moment I do this manually and it obviously works fine. Just wanted some VBA code to do
    this automatically so I can assign it to a toolbar button. Have bought a couple of books that have been no good, and searched and searched for an answer.

    I have done a little VBA before, but having searched around I am a
    bit lost on this. Or maybe it cant be done...

    Any help very greatfully received.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    There are a couple of things that you will come up against, but this is do-able.

    You could write some VBA to start the mailmerge wizard and try
    to populate the parameters. Although this may bring up the
    Outlook Security box informing you that a program is trying to
    access your Outlook.

    Give me some time to write an example.
    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
    Junior Member
    Join Date
    Apr 2004
    Posts
    22
    Thanks for replying at last a response, to correct the above I ahve now had 2 other responses, both saying "when you find out can you let me know"

    VBA help for Outlook is really scant out there, unless you want to mass email.

    Thanks

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Almost done!
    I just need to know what type of merge you want to do...

    1.) Form Letters
    2.) Mailing Labels
    3.) Envelopes
    4.) Catalog

    Also, what version of Outlook are you running?
    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
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    There is no direct access to the mailmerge process, so I hope
    what I have done so far is ok. I added a new menu item that is
    only enabled if there is a Contact Item selected. it then takes the
    selection and automates the mailmerge wizard. One requirement
    is that your Outlook and Word versions must be the same.

    I also need to know before I can finish is if this is going into an
    existing Word doc or a new one and the type of merge as I
    posted in the preceding post.

    Let me know when you get the change.
    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

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Everything is done but this part.
    1.) Form Letters
    2.) Mailing Labels
    3.) Envelopes
    4.) Catalog

    Also, what version of Outlook are you running?
    and merge to new document or existing one?

    ???
    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
    Junior Member
    Join Date
    Apr 2004
    Posts
    22
    Hi Rob

    Sorry for not getting back earlier, I have been out of the loop for a few days. Answering your posts in order: -

    The type of Merge is form letter, BTW the Contact form I merge from has loads of custom fields on it, dont know whether this will make a difference with your code.

    I am using Outlook 2003 11.5608.5703.

    This is going into an existing merge ( 1 of 5 standard files we can use depending on the contacts requirements)

    I cant believe you have moved so fast on this, I have had 3 months of returning back to forums seeing ) Replies to this.

    Many Many Thanks

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    The first thing I see it the need for determining which mailmerge
    document to use. What are the conditions that determine which
    mailmerge document to use?

    I don't know off hand if the custom contact form will cause an
    issue, but what I am doing is automating the Mail Merge wizard.
    So, if it works with your custom form manually then it should be
    ok.

    BTW, there is no programatic access to the mail merge wizard,
    but this could be simulated using the Word Object Model. It is
    just more time consuming writting more code. This is why I opted
    to automate the wizard.

    The version of Word, I assume, is the same as your Outlook?
    If its different then it needs to be upgraded. We are running the
    same version of Outlook so that is a plus.

    The last thing is that I forgot to send my updated VBA code back
    to work last night, so I will try to complete it here at work from
    memory.

    If using different mailmerge documents becomes an issue to
    determine, then I will write the code to manually duplicate the
    wizard, but I would like to avoid that. There is a saying that - if it
    aint broke, then don't fix it. So if the wizard can be used then I
    will use it.

    PS. don't worry about the delay, it just gave me more time to
    finish this. It actually works great on new blank mailmerge
    documents. I have it so the menu item is disabled unless a
    contact item is selected. And if more than one item is selected
    then it is disabled too. There is only a problem when it comes to
    entering the existing word document into the wizard because
    Outlook actually opens it for verification. I am still looking into
    working around this. Probably not too hard.

    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

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Apr 2004
    Posts
    22
    Hi Rob

    Thanks for the update.

    Firstly it is difficult to programatically work out which of the standard letters should be used, would it be possible to show a menu / toolbar button for all of the letters when a contact is highlighted ?

    The version of word is the same 11.0 (2003).

    I see what you say about verification of existing mailmerge document, because it does that when we do it manually.

    Many months ago I thought this would be so easy to do with VBA. Many postings and no replies later I now realise that it is not as easy as I thought. Many of the top gurus out there who will remain nameless shyed away from it.

    Many thanks for your continued enthusiasm.

    Would it help you if I emailed the Custom Form we use and the 5 mailmerge docs to you?

    One last thought the pst we use is legacy 97-2002 not 2003 format, does this present a problem. I guess if it does I can do an Export Import to update this.

    All the best for Easter to you and yours.

  10. #10
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Yes it would help to have the form and the 5 mm docs. I was
    thinking of adding to the SelectionChange event to read the
    custom field that contained the mm document name, I assume
    that it is in your custom form. Then when the menu item is clicked
    I have all the info I need to populate the wizard.
    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

  11. #11

    Thread Starter
    Junior Member
    Join Date
    Apr 2004
    Posts
    22
    Your email is dissabled at this forum if you want to keep it hidden send me a mail at [email protected] and I will forward you the MM dics and custom form.

    The Mailmerge doc is not encoded into the custom form anywere as there can be a number of different instances of letters sent to the same contact

    It is basically a booking system we run for Pilates Classes, taking initial a contacts details and then sending either a booking confirmation letter, a beginners workshop letter, a One to One session letter, a request for a completed health questionnaire....etc

    I never make things simple.

  12. #12
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    So basically you make a cognative decision of what document to
    send the contact? So, if that is true then maybe I can add menu
    items for each type of document? main menu of "Mail Merge
    Single Contact" and have sub menu items of the five different
    document types? This way the user will select the contact and
    then go to the menu and select the document type to use?
    Sounds ok to me. How about you?
    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

  13. #13

    Thread Starter
    Junior Member
    Join Date
    Apr 2004
    Posts
    22

    Thumbs up

    Sounds Bloody Brilliant to me ...

  14. #14
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Ok, menus are all done. I made it so each menu item passes a
    parameter to a .exe watcher program I wrote to watch for the
    Mail Merge Wizard. This needs to be this way because the wizard
    is modal and once the wizard came up the code would be halted.
    When the wizard appears the watcher automates it and places
    the document name in the appropriate textbox. I also added a
    menu item if you want it to go to a new blank word document.
    I have some more testing to do on verifiying the existing word
    document, but I know I can get it to work.

    Can't wait for you to try it out!

    I will probably be posting the completed projects tomorrow morning.

    Don't forget that when I get those files I will still have to see if it
    works with the custom form and docs.

    Later.
    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

  15. #15

    Thread Starter
    Junior Member
    Join Date
    Apr 2004
    Posts
    22
    Hi Rob

    I sent you the files yesterday did you not receive them.?

    Cheers

  16. #16
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    I just got the new attachment.
    I get this error message when I try to open the form in Outlook.



    And then my Outlook crashes.

    Also, there are now 7 mm documents, so I assume that I will
    make adjustments to the vba to add the seventh option.
    Attached Images Attached Images  
    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

  17. #17
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Ok, I was able to get the form published and installed, but if I go
    into design mode the form looks corrupted or something?

    Also, I don't know if its because some of the code has been
    disabled from running, I don't know if the issues are from that, but
    it looks like it is not picking up the custome fields in the mail
    merge. I think its because of the custom fields are bould to the
    form and not defined in the folder. Again this may not be an issue
    for yours since it is running all code.

    I will be posting the code in a few after I make a couple of changes.
    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
    Junior Member
    Join Date
    Apr 2004
    Posts
    22
    Aha, I just remembered it looks corrupted coz there is an ie6 object sitting over the top which in run mode is invisible untill I want to show a map to the contacts address.

    Just delete the ie6 object which should fill the whole of the form on the upmost layer.

    Sorry bout there being 7 ..... and sorry bout crashing your outlook, there is no malicious code in there, just my badly coded VBscript...LOL

  19. #19
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Here is the code to add the menu items and detect the selection
    type and count. It will disable the menu items if the selection is
    not a contact item type or if more than one item is selected. I
    added one main menu item for the single mailmerge with a
    description of the item selected. Then I add eight sub menu
    items. One for merge to a new document and seven more for
    each pre-existing mailmerge document.

    The menu items shell out a watcher program I wrote to automate
    the Mail merge wizard with the predefined settings you
    requested. The shell passes a file path and document name
    parameter to the watcher, thus giving it all the info itneeds to
    automate the wizard. the reason I have to use a watcher
    program is that when the wizard gets invoked it is modal and all
    code execution is halted until it is closed. The watcher program is
    shelled out one line of code before the wizard is invoked.

    I think there is an issue with the custom fields you have on your
    custom form because yoyu have created the fileds to be saved in
    the item and not the folder. So the mailmerge doesn't see the
    custom fields. I couldn't get your form to run correctly so I can not
    verify that this will be the case.

    Let me know what you think.

    Happy mailmerging!

    Code on following posts.
    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

  20. #20
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Change the document paths to reflect your paths.
    Copy and paste into your "ThisOutlookSession" class.

    Outlook VBA Code...
    VB Code:
    1. Option Explicit
    2.  
    3. Public WithEvents SyncSMM1 As Office.CommandBarButton
    4. Public WithEvents SyncSMM2 As Office.CommandBarButton
    5. Public WithEvents SyncSMM3 As Office.CommandBarButton
    6. Public WithEvents SyncSMM4 As Office.CommandBarButton
    7. Public WithEvents SyncSMM5 As Office.CommandBarButton
    8. Public WithEvents SyncSMM6 As Office.CommandBarButton
    9. Public WithEvents SyncSMM7 As Office.CommandBarButton
    10. Public WithEvents SyncSMMNew As Office.CommandBarButton
    11.  
    12. Public gcbTools As Office.CommandBarPopup
    13. Public gcbMM As Office.CommandBarButton
    14. Public gcbSMM As Office.CommandBarPopup
    15. Public gcbSMM1 As Office.CommandBarButton
    16. Public gcbSMM2 As Office.CommandBarButton
    17. Public gcbSMM3 As Office.CommandBarButton
    18. Public gcbSMM4 As Office.CommandBarButton
    19. Public gcbSMM5 As Office.CommandBarButton
    20. Public gcbSMM6 As Office.CommandBarButton
    21. Public gcbSMM7 As Office.CommandBarButton
    22. Public gcbSMMNew As Office.CommandBarButton
    23.  
    24. Public WithEvents goExp As Outlook.Explorer
    25.  
    26. 'SETUP THE MENUS
    27. Private Sub Application_MAPILogonComplete()
    28. '<RR VB/OUTLOOK GURU 04/05/04>
    29.     Set gcbTools = Application.ActiveExplorer.CommandBars("Menu Bar").Controls("Tools")
    30. '    gcbTools.Reset
    31.     'ADD THE MAIN MENU ITEM FOR THE NEW MAIL MERGE
    32.     Set gcbSMM = gcbTools.Controls.Add(msoControlPopup, 1, "SMM", , True)
    33.     With gcbSMM
    34.         .BeginGroup = True
    35.         .Caption = "Single Mail Merge of Contact Item"
    36.         .Visible = True
    37.         .DescriptionText = "Execute a Mail Merge on a Contact Item"
    38.         .TooltipText = "Execute a Mail Merge on a Contact Item"
    39.         .Tag = "888"
    40.         .Enabled = True
    41.         .Style = msoControlCustom
    42.     End With
    43.     'ADD THE NEW SUB MENU ITEM
    44.     Set gcbSMMNew = gcbSMM.Controls.Add(msoControlButton, 1, "SMMNew", , True)
    45.     With gcbSMMNew
    46.         .Caption = "Mail Merge Using a New Document"
    47.         .Visible = True
    48.         .DescriptionText = "Execute a Mail Merge on a Contact Item"
    49.         .TooltipText = "Execute a Mail Merge on a Contact Item"
    50.         .Tag = "880"
    51.         .Enabled = True
    52.         .Style = msoControlCustom
    53.     End With
    54.     Call SyncSMMNewButton(gcbSMMNew)
    55.     'ADD THE FIRST SUB MENU ITEM
    56.     Set gcbSMM1 = gcbSMM.Controls.Add(msoControlButton, 1, "SMM1", , True)
    57.     With gcbSMM1
    58.         .BeginGroup = True
    59.         .Caption = "Mail Merge Using Doc1.doc"
    60.         .Visible = True
    61.         .DescriptionText = "Execute a Mail Merge on a Contact Item"
    62.         .TooltipText = "Execute a Mail Merge on a Contact Item"
    63.         .Tag = "881"
    64.         .Enabled = True
    65.         .Style = msoControlCustom
    66.     End With
    67.     Call SyncSMM1Button(gcbSMM1)
    68.     'ADD THE SECOND SUB MENU ITEM
    69.     Set gcbSMM2 = gcbSMM.Controls.Add(msoControlButton, 1, "SMM2", , True)
    70.     With gcbSMM2
    71.         .Caption = "Mail Merge Using Doc2.doc"
    72.         .Visible = True
    73.         .DescriptionText = "Execute a Mail Merge on a Contact Item"
    74.         .TooltipText = "Execute a Mail Merge on a Contact Item"
    75.         .Tag = "882"
    76.         .Enabled = True
    77.         .Style = msoControlCustom
    78.     End With
    79.     Call SyncSMM2Button(gcbSMM2)
    80.     'ADD THE THIRD SUB MENU ITEM
    81.     Set gcbSMM3 = gcbSMM.Controls.Add(msoControlButton, 1, "SMM3", , True)
    82.     With gcbSMM3
    83.         .Caption = "Mail Merge Using Doc3.doc"
    84.         .Visible = True
    85.         .DescriptionText = "Execute a Mail Merge on a Contact Item"
    86.         .TooltipText = "Execute a Mail Merge on a Contact Item"
    87.         .Tag = "883"
    88.         .Enabled = True
    89.         .Style = msoControlCustom
    90.     End With
    91.     Call SyncSMM3Button(gcbSMM3)
    92.     'ADD THE FOURTH SUB MENU ITEM
    93.     Set gcbSMM4 = gcbSMM.Controls.Add(msoControlButton, 1, "SMM4", , True)
    94.     With gcbSMM4
    95.         .Caption = "Mail Merge Using Doc4.doc"
    96.         .Visible = True
    97.         .DescriptionText = "Execute a Mail Merge on a Contact Item"
    98.         .TooltipText = "Execute a Mail Merge on a Contact Item"
    99.         .Tag = "884"
    100.         .Enabled = True
    101.         .Style = msoControlCustom
    102.     End With
    103.     Call SyncSMM4Button(gcbSMM4)
    104.     'ADD THE FIFTH SUB MENU ITEM
    105.     Set gcbSMM5 = gcbSMM.Controls.Add(msoControlButton, 1, "SMM5", , True)
    106.     With gcbSMM5
    107.         .Caption = "Mail Merge Using Doc5.doc"
    108.         .Visible = True
    109.         .DescriptionText = "Execute a Mail Merge on a Contact Item"
    110.         .TooltipText = "Execute a Mail Merge on a Contact Item"
    111.         .Tag = "885"
    112.         .Enabled = True
    113.         .Style = msoControlCustom
    114.     End With
    115.     Call SyncSMM5Button(gcbSMM5)
    116.     'ADD THE SIXTH SUB MENU ITEM
    117.     Set gcbSMM6 = gcbSMM.Controls.Add(msoControlButton, 1, "SMM6", , True)
    118.     With gcbSMM6
    119.         .Caption = "Mail Merge Using Doc6.doc"
    120.         .Visible = True
    121.         .DescriptionText = "Execute a Mail Merge on a Contact Item"
    122.         .TooltipText = "Execute a Mail Merge on a Contact Item"
    123.         .Tag = "886"
    124.         .Enabled = True
    125.         .Style = msoControlCustom
    126.     End With
    127.     Call SyncSMM6Button(gcbSMM6)
    128.     'ADD THE SEVENTH SUB MENU ITEM
    129.     Set gcbSMM7 = gcbSMM.Controls.Add(msoControlButton, 1, "SMM7", , True)
    130.     With gcbSMM7
    131.         .Caption = "Mail Merge Using Doc7.doc"
    132.         .Visible = True
    133.         .DescriptionText = "Execute a Mail Merge on a Contact Item"
    134.         .TooltipText = "Execute a Mail Merge on a Contact Item"
    135.         .Tag = "887"
    136.         .Enabled = True
    137.         .Style = msoControlCustom
    138.     End With
    139.     Call SyncSMM7Button(gcbSMM7)
    140.    
    141.     Set goExp = Application.ActiveExplorer
    142.    
    143. End Sub
    144.  
    145. Private Sub goExp_SelectionChange()
    146.  
    147.     Dim oExp As Outlook.Explorer
    148.     Dim oFolder As Outlook.MAPIFolder
    149.     Dim oSel As Outlook.Selection
    150.     Dim oItems As Outlook.Items
    151.     Dim vType As Variant
    152.    
    153.     Set oExp = Outlook.ActiveExplorer
    154.     Set oFolder = Outlook.ActiveExplorer.CurrentFolder
    155.     If oFolder.DefaultItemType <> olContactItem Then
    156.         gcbSMM.Enabled = False
    157.         GoTo ClearAndExit
    158.     Else
    159.         If oFolder.DefaultMessageClass <> "IPM.Contact" Then
    160.             gcbSMM.Enabled = False
    161.             GoTo ClearAndExit
    162.         End If
    163.     End If
    164.     Set oSel = oExp.Selection
    165.     If oSel.Count > 0 Then
    166.         Select Case oSel.Item(1).Class
    167.             Case olTask
    168.                 vType = "Task"
    169.             Case olMail
    170.                 vType = "Email"
    171.             Case olContact
    172.                 vType = "Contact"
    173.             Case olJournal
    174.                 vType = "Journal"
    175.             Case olNote
    176.                 vType = "Note"
    177.             Case olAppointment
    178.                 vType = "Calendar"
    179.             Case Else
    180.                 vType = "Unknown Type!"
    181.         End Select
    182.     Else
    183.         gcbSMM.Enabled = False
    184.         GoTo ClearAndExit
    185.     End If
    186.     If oSel.Count > 1 Then
    187.         gcbSMM.Enabled = False
    188.         GoTo ClearAndExit
    189.     ElseIf oSel.Item(1).Class = olContact And vType = "Contact" Then
    190.         gcbSMM.Enabled = True
    191.         gcbSMM.Caption = "Single Mail Merge of Contact Item '" & oSel.Item(1) & "'"
    192.         Set gcbMM = gcbTools.CommandBar.FindControl(msoControlButton, gcbTools.Controls("Mail Mer&ge...").ID, , , True)
    193.     Else
    194.         gcbSMM.Enabled = False
    195.         GoTo ClearAndExit
    196.     End If
    197.    
    198. ClearAndExit:
    199.     Set oExp = Nothing
    200.     Set oFolder = Nothing
    201.     Set oSel = Nothing
    202.    
    203. End Sub
    Last edited by RobDog888; Apr 16th, 2004 at 11:21 AM.
    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

  21. #21
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    More VBA Code...
    VB Code:
    1. 'SETUP THE EVENTS FOR THE MENUITEMS
    2. Private Sub SyncSMMNew_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
    3. '<RR VB/OUTLOOK GURU 04/05/04>
    4.     Select Case Ctrl.Tag
    5.         Case "880"
    6.             Call SelectedMailMerge("New")
    7.         Case Else
    8.             CancelDefault = True
    9.     End Select
    10. End Sub
    11.  
    12. Private Sub SyncSMMNewButton(btn As Office.CommandBarButton)
    13. '<RR VB/OUTLOOK GURU 04/05/04>
    14.     Set SyncSMMNew = btn
    15.     If btn Is Nothing Then
    16.         MsgBox "Sync. of '" & btn.Caption & "' button event failed!", vbCritical + vbOKOnly
    17.     End If
    18. End Sub
    19.  
    20. Private Sub SyncSMM1_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
    21. '<RR VB/OUTLOOK GURU 04/05/04>
    22.     Select Case Ctrl.Tag
    23.         Case "881"
    24.             Call SelectedMailMerge("D:\My Documents\Doc1.doc")
    25.         Case Else
    26.             CancelDefault = True
    27.     End Select
    28. End Sub
    29.  
    30. Private Sub SyncSMM1Button(btn As Office.CommandBarButton)
    31. '<RR VB/OUTLOOK GURU 04/05/04>
    32.     Set SyncSMM1 = btn
    33.     If btn Is Nothing Then
    34.         MsgBox "Sync. of '" & btn.Caption & "' button event failed!", vbCritical + vbOKOnly
    35.     End If
    36. End Sub
    37.  
    38. Private Sub SyncSMM2_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
    39. '<RR VB/OUTLOOK GURU 04/05/04>
    40.     Select Case Ctrl.Tag
    41.         Case "882"
    42.             Call SelectedMailMerge("D:\My Documents\Doc2.doc")
    43.         Case Else
    44.             CancelDefault = True
    45.     End Select
    46. End Sub
    47.  
    48. Private Sub SyncSMM2Button(btn As Office.CommandBarButton)
    49. '<RR VB/OUTLOOK GURU 04/05/04>
    50.     Set SyncSMM2 = btn
    51.     If btn Is Nothing Then
    52.         MsgBox "Sync. of '" & btn.Caption & "' button event failed!", vbCritical + vbOKOnly
    53.     End If
    54. End Sub
    55.  
    56. Private Sub SyncSMM3_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
    57. '<RR VB/OUTLOOK GURU 04/05/04>
    58.     Select Case Ctrl.Tag
    59.         Case "883"
    60.             Call SelectedMailMerge("D:\My Documents\Doc3.doc")
    61.         Case Else
    62.             CancelDefault = True
    63.     End Select
    64. End Sub
    65.  
    66. Private Sub SyncSMM3Button(btn As Office.CommandBarButton)
    67. '<RR VB/OUTLOOK GURU 04/05/04>
    68.     Set SyncSMM3 = btn
    69.     If btn Is Nothing Then
    70.         MsgBox "Sync. of '" & btn.Caption & "' button event failed!", vbCritical + vbOKOnly
    71.     End If
    72. End Sub
    73.  
    74. Private Sub SyncSMM4_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
    75. '<RR VB/OUTLOOK GURU 04/05/04>
    76.     Select Case Ctrl.Tag
    77.         Case "884"
    78.             Call SelectedMailMerge("D:\My Documents\Doc4.doc")
    79.         Case Else
    80.             CancelDefault = True
    81.     End Select
    82. End Sub
    83.  
    84. Private Sub SyncSMM4Button(btn As Office.CommandBarButton)
    85. '<RR VB/OUTLOOK GURU 04/05/04>
    86.     Set SyncSMM4 = btn
    87.     If btn Is Nothing Then
    88.         MsgBox "Sync. of '" & btn.Caption & "' button event failed!", vbCritical + vbOKOnly
    89.     End If
    90. End Sub
    91.  
    92. Private Sub SyncSMM5_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
    93. '<RR VB/OUTLOOK GURU 04/05/04>
    94.     Select Case Ctrl.Tag
    95.         Case "885"
    96.             Call SelectedMailMerge("D:\My Documents\Doc5.doc")
    97.         Case Else
    98.             CancelDefault = True
    99.     End Select
    100. End Sub
    101.  
    102. Private Sub SyncSMM5Button(btn As Office.CommandBarButton)
    103. '<RR VB/OUTLOOK GURU 04/05/04>
    104.     Set SyncSMM5 = btn
    105.     If btn Is Nothing Then
    106.         MsgBox "Sync. of '" & btn.Caption & "' button event failed!", vbCritical + vbOKOnly
    107.     End If
    108. End Sub
    109.  
    110. Private Sub SyncSMM6_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
    111. '<RR VB/OUTLOOK GURU 04/05/04>
    112.     Select Case Ctrl.Tag
    113.         Case "886"
    114.             Call SelectedMailMerge("D:\My Documents\Doc6.doc")
    115.         Case Else
    116.             CancelDefault = True
    117.     End Select
    118. End Sub
    119.  
    120. Private Sub SyncSMM6Button(btn As Office.CommandBarButton)
    121. '<RR VB/OUTLOOK GURU 04/05/04>
    122.     Set SyncSMM6 = btn
    123.     If btn Is Nothing Then
    124.         MsgBox "Sync. of '" & btn.Caption & "' button event failed!", vbCritical + vbOKOnly
    125.     End If
    126. End Sub
    127.  
    128. Private Sub SyncSMM7_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
    129. '<RR VB/OUTLOOK GURU 04/05/04>
    130.     Select Case Ctrl.Tag
    131.         Case "887"
    132.             Call SelectedMailMerge("D:\My Documents\Doc7.doc")
    133.         Case Else
    134.             CancelDefault = True
    135.     End Select
    136. End Sub
    137.  
    138. Private Sub SyncSMM7Button(btn As Office.CommandBarButton)
    139. '<RR VB/OUTLOOK GURU 04/05/04>
    140.     Set SyncSMM7 = btn
    141.     If btn Is Nothing Then
    142.         MsgBox "Sync. of '" & btn.Caption & "' button event failed!", vbCritical + vbOKOnly
    143.     End If
    144. End Sub
    145.  
    146. Private Function SelectedMailMerge(ByVal sDocument As String)
    147. '<RR VB/OUTLOOK GURU 04/05/04>
    148.     gcbSMM.Enabled = True
    149.     Set gcbMM = gcbTools.CommandBar.FindControl(msoControlButton, gcbTools.Controls("Mail Mer&ge...").ID, , , True)
    150.     'CHANGE THIS PATH TO REFLECT WHERE YOU SAVED IT
    151.     Shell "D:\Development\Outlook\Mail Merge\MMWatcher.exe /" & sDocument, vbHide
    152.     gcbMM.Execute
    153. End Function
    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

  22. #22
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    This is the VB Code for the Watcher program that automates the
    Mailmerge wizard in Outlook. Compile it and copy it over to the
    corresponding path you enter in the "SelectedMailMerge"
    procedure in the VBA Code.

    You can easily make changes to the code by uncommenting
    thelines for things like merge to, etc.

    VB Code...
    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
    4. (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    5.  
    6. Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
    7. (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
    8.  
    9. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
    10. (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    11.  
    12. Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" _
    13. (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    14.  
    15. Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" _
    16. (ByVal hwnd As Long) As Long
    17.  
    18. Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
    19. ByVal wParam As Long, ByVal lParam As Long) As Long
    20.  
    21. Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, _
    22. ByVal nMaxCount As Long) As Long
    23.  
    24. Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
    25.  
    26. Private Declare Function GetDlgCtrlID Lib "user32" (ByVal hwnd As Long) As Long
    27.  
    28. Private Declare Function CheckRadioButton Lib "user32" (ByVal hDlg As Long, ByVal nIDFirstButton As Long, _
    29. ByVal nIDLastButton As Long, ByVal nIDCheckButton As Long) As Long
    30.  
    31. Private Declare Function PutFocus Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) As Long
    32.  
    33. Private Const GW_HWNDNEXT = 2
    34. Private Const GW_OWNER = 4
    35.  
    36. Private Const BM_CLICK = &HF5
    37.  
    38. Private Const WM_CLOSE = &H10
    39. Private Const WM_COMMAND = &H111
    40. Private Const WM_GETTEXT = &HD
    41. Private Const WM_GETTEXTLENGTH = &HE
    42. Private Const WM_KEYDOWN = &H100
    43. Private Const WM_KEYUP = &H101
    44. Private Const WM_SETTEXT As Long = &HC
    45. Private Const WM_LBUTTONDOWN = &H201
    46. Private Const WM_LBUTTONUP = &H202
    47. Private Const WM_LBUTTONDBLCLK As Long = &H203
    48. Private Const WM_PASTE As Long = &H302
    49. Private Const WM_COPY As Long = &H301
    50. Private Const WM_COPYDATA As Long = &H4A
    51. Private Const WM_CUT As Long = &H300
    52.  
    53. Private Const CB_FINDSTRINGEXACT = &H158
    54. Private Const CB_ERR = (-1)
    55. Private Const CB_FINDSTRING = &H14C
    56. Private Const CB_GETCOUNT = &H146
    57. Private Const CB_GETCURSEL = &H147
    58. Private Const CB_GETTOPINDEX = &H15B
    59. Private Const CB_SETCURSEL = &H14E
    60. Private Const CB_SHOWDROPDOWN = &H14F
    61.  
    62. Private Const VK_DOWN = &H28
    63. Private Const VK_UP = &H26
    64. Private Const VK_SELECT = &H29
    65. Private Const VK_SPACE = &H20
    66. Private Const VK_TAB = &H9
    67.  
    68. Private mlHwnd As Long
    69. Private mlHwndSel As Long
    70. Private mlHwndFields As Long
    71. Private mlHwndExistDoc As Long
    72. Private mlHwndExistDocPath As Long
    73. Private mlHwndDocType As Long
    74. Private mlHwndMergeTo As Long
    75. Private mlHwndBrowse1 As Long
    76. Private mlHwndCD As Long
    77. Private mlHwndCDPath As Long
    78. Private mlHwndCDOK As Long
    79. Private mlHwndOK As Long
    80.  
    81. Public Sub Main()
    82.  
    83.     Dim rtn As Long
    84.     Dim arSwitches() As String
    85.     Dim i As Integer
    86.    
    87.     Do While FindWindow("#32770", "Mail Merge Contacts") = 0
    88.         DoEvents
    89.     Loop
    90.     mlHwnd = FindWindow("#32770", "Mail Merge Contacts")
    91.    
    92.     arSwitches = Split(Command, "/")
    93.     If UBound(arSwitches) = 0 Then
    94.         MsgBox "Missing startup parameter!", vbOKOnly + vbCritical
    95.         End
    96.     End If
    97.    
    98.     'SELECT ONLY SELECTED CONTACTS
    99.     mlHwndSel = FindWindowEx(mlHwnd, 0&, "Button", "&Only selected contacts")
    100.     rtn = SendMessage(mlHwndSel, WM_LBUTTONDOWN, ByVal 0&, ByVal 0& )
    101.     rtn = SendMessage(mlHwndSel, WM_LBUTTONUP, ByVal 0&, ByVal 0& )
    102.    
    103.     'SELECT ALL CONTACT FIELDS
    104.     mlHwndFields = FindWindowEx(mlHwnd, 0&, "Button", "All contact &fields")
    105.     rtn = SendMessage(mlHwndFields, WM_LBUTTONDOWN, ByVal 0&, ByVal 0& )
    106.     rtn = SendMessage(mlHwndFields, WM_LBUTTONUP, ByVal 0&, ByVal 0& )
    107.    
    108.     'SELECT PATH TO NEW/EXISTING DOCUMENT
    109.     If arSwitches(1) = "New" Then
    110.         mlHwndExistDoc = FindWindowEx(mlHwnd, 0&, "Button", "&New document")
    111.     Else
    112.         mlHwndExistDoc = FindWindowEx(mlHwnd, 0&, "Button", "&Existing document:")
    113.     End If
    114.     rtn = SendMessage(mlHwndExistDoc, WM_LBUTTONDOWN, ByVal 0&, ByVal 0& )
    115.     rtn = SendMessage(mlHwndExistDoc, WM_LBUTTONUP, ByVal 0&, ByVal 0& )
    116.    
    117.     'SELECT THE DOCUMENT TYPE
    118.     mlHwndDocType = FindWindowEx(mlHwnd, 0&, "REComboBox20W", vbNullString)
    119.     rtn = SendMessage(mlHwndDocType, CB_SHOWDROPDOWN, ByVal 1, ByVal 0& ) 'DROPDOWN
    120.     If rtn = 1 Then
    121.         'ALREADY SELECTED BY DEFAULT. IF NOT CHANGE SO ITS SYNCHED
    122.         'FORM LETTERS
    123.         rtn = SendMessage(mlHwndDocType, CB_SETCURSEL, 0&, 0& ) 'SET TO FIRST OPTION
    124.         'MAILING LABELS
    125. ''        rtn = SendMessage(mlHwndDocType, WM_KEYDOWN, VK_DOWN, 0& ) 'MOVE DOWN 1
    126. ''        rtn = SendMessage(mlHwndDocType, WM_KEYUP, VK_DOWN, 0& )
    127.         'ENVELOPES
    128. ''        rtn = SendMessage(mlHwndDocType, WM_KEYDOWN, VK_DOWN, 0& ) 'MOVE DOWN 1
    129. ''        rtn = SendMessage(mlHwndDocType, WM_KEYUP, VK_DOWN, 0& )
    130.         'CATALOGS
    131. ''        rtn = SendMessage(mlHwndDocType, WM_KEYDOWN, VK_DOWN, 0& ) 'MOVE DOWN 1
    132. ''        rtn = SendMessage(mlHwndDocType, WM_KEYUP, VK_DOWN, 0& )
    133.         'MAKE THE SELECTION
    134.         rtn = SendMessage(mlHwndDocType, CB_SETCURSEL, ByVal 0&, ByVal 0& ) 'MAKE SELECTION
    135.         rtn = SendMessage(mlHwndDocType, WM_LBUTTONDOWN, ByVal 0&, ByVal 0& )
    136.         rtn = SendMessage(mlHwndDocType, WM_LBUTTONUP, ByVal 0&, ByVal 0& )
    137.         rtn = SendMessage(mlHwndDocType, CB_SHOWDROPDOWN, ByVal 0, ByVal 0& ) 'CLOSE UP
    138.     End If
    139.    
    140.     'MERGE TO:
    141.     mlHwndMergeTo = GetWindow(mlHwndDocType, GW_HWNDNEXT)
    142.     mlHwndMergeTo = GetWindow(mlHwndMergeTo, GW_HWNDNEXT)
    143.     rtn = SendMessage(mlHwndMergeTo, CB_SHOWDROPDOWN, ByVal 1, ByVal 0& ) 'DROPDOWN
    144.     If rtn = 1 Then
    145.         'NEW DOCUMENT
    146.         rtn = SendMessage(mlHwndMergeTo, CB_SETCURSEL, 0&, 0& ) 'SET TO FIRST OPTION
    147.         'PRINTER
    148. '        rtn = SendMessage(mlHwndMergeTo, WM_KEYDOWN, VK_DOWN, 0& ) 'MOVE DOWN 1
    149. '        rtn = SendMessage(mlHwndMergeTo, WM_KEYUP, VK_DOWN, 0& )
    150.         'EMAIL ADDRESS
    151. '        rtn = SendMessage(mlHwndMergeTo, WM_KEYDOWN, VK_DOWN, 0& ) 'MOVE DOWN 1
    152. '        rtn = SendMessage(mlHwndMergeTo, WM_KEYUP, VK_DOWN, 0& )
    153.         'MAKE THE SELECTION
    154.         rtn = SendMessage(mlHwndMergeTo, CB_SETCURSEL, ByVal 0&, ByVal 0& ) 'MAKE SELECTION - MAILING LABELS
    155.         rtn = SendMessage(mlHwndMergeTo, WM_LBUTTONDOWN, ByVal 0&, ByVal 0& )
    156.         rtn = SendMessage(mlHwndMergeTo, WM_LBUTTONUP, ByVal 0&, ByVal 0& )
    157.         rtn = SendMessage(mlHwndMergeTo, CB_SHOWDROPDOWN, ByVal 0, ByVal 0& ) 'CLOSE UP
    158.     End If
    159.    
    160.     'ENTER THE PATH IF PARAMETER IS A EXISTING DOCUMENT TYPE
    161.     If arSwitches(1) <> "New" Then
    162.         'NEED TO PASTE THE FILE APTH IN SO IT TRIGGERS THE VERIFICATION OF DOCUMENT BY OUTLOOK
    163.         Clipboard.Clear
    164.         Clipboard.SetText arSwitches(1) 'FILE PATH AND NAME
    165.         mlHwndExistDocPath = FindWindowEx(mlHwnd, 0&, "RichEdit20WPT", vbNullString)
    166. '        rtn = SendMessage(mlHwndExistDocPath, WM_SETTEXT, 0&, ByVal "D:\My Documents\Doc1.doc")
    167.         rtn = SendMessage(mlHwndExistDocPath, WM_LBUTTONDOWN, ByVal 0&, ByVal 0& )
    168.         rtn = SendMessage(mlHwndExistDocPath, WM_LBUTTONUP, ByVal 0&, ByVal 0& )
    169.         rtn = PutFocus(mlHwndExistDocPath)
    170.         rtn = SendMessage(mlHwndExistDocPath, WM_PASTE, ByVal 0&, ByVal 0& )
    171.         rtn = PutFocus(mlHwndExistDocPath)
    172.         rtn = SendMessage(mlHwndExistDocPath, WM_LBUTTONDBLCLK, ByVal 0&, ByVal 0& )
    173.     End If
    174.    
    175.     'CLICK OK
    176.     mlHwndOK = FindWindowEx(mlHwnd, 0&, "Button", "OK")
    177.     PostMessage mlHwndOK, BM_CLICK, 0&, 0&
    178.    
    179. End Sub
    Attached Files Attached Files
    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

  23. #23
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    One more thing. If you want to merge to a email address then we
    will need to change the code a bit since when the option is
    selected it make a textbox become visible for the email address
    entry. We would need to get the handel to this textbox and enter
    the address in.

    Later.
    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

  24. #24

    Thread Starter
    Junior Member
    Join Date
    Apr 2004
    Posts
    22
    Hi Robb

    Pasted the code in to "This outlook Session" and got the following error message when running the macro

    Compile Error:

    Only Valid in Object Module

    This is at the first Public WithEvents Call line 4

    I guess this is something I am doing ......

    At this stage I have not compiled and saved the watcher.

    Any Ideas

    BTW I have sent you a screen shot via email, and if i comment out each of the Public WithEvents it fails at the next.

  25. #25
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    According to your screenshot, you pasted the code into a module.
    This is not allowed for a Public WithEvents. It is supossed to be
    pasted into the "thisOutlookSession" class in the node above the
    module named "Microsoft Office Outlook Objects". The code
    needs to be in theat class so it can be instanciated as a class
    object.



    That will solve all issues.

    HTH.
    Attached Images Attached Images  
    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

  26. #26
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Sorry, my mistake. When I was copying the code over I added
    the .Style property after in the vbforums reply box manually and I
    added it to the CommandBarPopup menuitem when its only for
    the CommandBarButton only. Take out that line only and that
    should do it.

    Attached Images Attached Images  
    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

  27. #27

    Thread Starter
    Junior Member
    Join Date
    Apr 2004
    Posts
    22
    Hi Robb

    Sorry for deviating to email, but for some reason I can not get a screen capture onto this forum.

    OK deleted the line in question, and the whole code runs without error.

    Maybe showing my ass here, but am I meant to paste the watcher code into one of the modules (1 or 2) next to the This outlook session to compile ?

    I have tried this but all I get is an undefined error on the clipboard command in Line 163. Commenting this out errors at the next clipboard line.

    Also what do I do with the mmwatcher zip file that has a number of files in it?

    Bet your wishing you never started this now

    Cheers

  28. #28
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Not at all. Dont worry about it.

    The .zip file is the watcher visual basic project - same as I posted.
    You need to compile the watcher program in VB6 not VBA. The
    watcher needs to be a separate program (not another module in
    VBA) because when the wizard comes up its modal which will
    stop all code execution. The watcher being separate will be able
    to continue to automate the wizard. Do you have VB6? If not I
    can compile it for you and post the exe file.

    We are almost there. Home stretch.

    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

  29. #29

    Thread Starter
    Junior Member
    Join Date
    Apr 2004
    Posts
    22
    Hi Rob

    No I do not have VB6, I would be ever so greatfull if you could compile and post the file.

    All The Best

  30. #30
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Here is the compiled exe for you with the settings of :
    Mail Merge Watcher™ for Outlook 2003 and Word 2003.
    Settings: "Only selected contacts", "All contact fields", "Existing"
    or "New" determined by commandline parameter, "Document
    Type = Form Letters", "Merge to" determined by commandline
    parameter.

    You only need the basic vb runtime files which should already be
    installed if you have Office w/VBA installed.

    You can view the settings under the comments property of the
    summary tab when you right click > properties on the
    unzipped .exe file.
    Attached Files Attached Files
    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

  31. #31

    Thread Starter
    Junior Member
    Join Date
    Apr 2004
    Posts
    22
    Hi Robb

    Things is starting to happen now, I get a menu option up when a contact is highlighted, I will do the final config on it tomorrow.

    Unfortunatelly I have not had any time over the weekend to play.

    I will look forward to fully testing it tomorrow

    All the best !

  32. #32
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Cool, I will keep an eye out for your next post.
    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

  33. #33

    Thread Starter
    Junior Member
    Join Date
    Apr 2004
    Posts
    22
    Good things to report !!!!

    You have earned your title of Guru...

    Essentially the code works, only bug I have to report is that if I try to do a manual mailmerge, the mmwatcher errors with: -

    Run time error 9
    Subscript out of range

    Dont know whether this means "jack" to you, coz it sure doent to me ....LOL

    Would it be cheaky to attach a bit of a wish list ?, i'l chance my arm anyway as you seem a decent guy.

    Would it be possible to have the menu options as toolbar buttons ?

    I have the office assistant running, so I get a popup asking me to firstly confirm a merge from the wizard, and then another one from outlook asking the same, would it be possible to "hush these"?

    and lastly would it be poss to autosave these, I have hiddent text at the top of the doc which creates the save bame automatically anyway, and could it also auto print.

    Now is that taking a mile...or what??

    Thank you so much for the effort you have put in, it is really appreciated.


    Cheers

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

    The only issue I could see is if there is no commandline parameter
    of either "New" or the existing document path/filename. I was
    trapping for that by checking for a 0 element in the array
    arSwitches. I tested it out and if no commandline switch then it
    actually returns a -1 not 0. I fixed that and attached a new
    compile. Check out the new exe icon!

    The only thing is that you say a "manual mailmerge". If that is the
    case then wouldnt you not need the watcher since you are doing
    it manually?

    Yes, we could make the toolbar, but then we would probably
    want to make this whole thing an official Outlook Add-In (maybe
    too much work, not that I can't do it or havent done one. More of
    a time issue). To make a toolbar we would need another class or
    two to add to the VBA.

    With the office assistant prompting you for acknowledgement
    I think there is a property we can change to turn it off temporarly.
    Let me look for it.

    "Autosave", if you mean to save the word mailmerge document
    after its created then yes and we can turn off the assistant
    prompts too.

    I'll be back.
    Attached Files Attached Files
    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

  35. #35

    Thread Starter
    Junior Member
    Join Date
    Apr 2004
    Posts
    22
    Hi Robb

    Tried the updated watcher, it triggers a Missing Startup Parameter when attempting to use the manual mailmerge, I agree with you that why would I be doing it manually as I now have an automatic method. Customers want the earth ...LOL

    Hushing the 2 confirmations to merge and autosaving would be a hell of a good icing on the cake though.

    If I disable the office assistant you still have to select the merge to new doc from the toolbar in word, and than click merge on the following dialog.

    Would it also be possible to print (with manual duplex selected) to the default printer at the same time in code ? if not too time consuming.

    The toolbar is a whim of mine and not so important, I dont want you to spend all your time on this, and am sure you have already spent a great deal of time already.

    Cheers

  36. #36
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    No, I really haven't spent too much time on this, just some
    lunches and "breaks" when I get bored with my current project at
    work.


    How are you trying to do a manual MM? Running the
    MMWatcher.exe directly? The MMWatcher.exe needs to be run
    from the Outlook menuitems only. That is why it tells you that it
    is missing a startup parameter. The Outlook menuitems are
    passing the parameter of the document path & filename or "New".

    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

  37. #37

    Thread Starter
    Junior Member
    Join Date
    Apr 2004
    Posts
    22
    When doing a manual mail merge I am selecting tools > mailmerge and then populating the dialog box manually.

    I execute the watcher by clicking on it manually, running from the outlook menu items, I dont understand this....why all of a sudden to I feel I have missed the point totally somewhere back down the line.

    Sorry to be such a clown....

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

    Automated mailmerge to a new word document...
    1.) Select a single contact item.
    2.) Click Tools > Mail merge using 'John doe' > Mail Merge Using a New Document.
    3.) The watcher is executed automatically, passing the "New" parameter to the watcher.
    4.) Word is opened with a mail merge recordset of a single record of the selected 'John Doe' contact.
    5.) Document is ready to be modified/printed.

    Automated mailmerge to an existing word document...
    1.) Select a single contact item.
    2.) Click Tools > Mail merge using 'John doe' > Mail Merge Using 'Debtor Chase up 2.doc'. (For example)
    3.) The watcher is executed automatically, passing the "Debtor Chase up 2.doc" parameter to the watcher.
    4.) Word is opened with a mail merge recordset of a single record of the selected 'John Doe' contact.
    5.) Document is ready to be modified/printed.

    Is this what you wanted to accomplish or are we mis-communicating?

    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

  39. #39

    Thread Starter
    Junior Member
    Join Date
    Apr 2004
    Posts
    22
    Aha

    I thought I had to manually start the watcher, or put it in startup folder.

    It all works OK if I start the watcher manually before outlook.

    However when I reboot from scratch, start outlook run the macro in outlook (my outlook installation sometimes want to reinstall part of outlook when I run a macro, christ knows why ???) and then select a contact it does not start the watcher automatically.

    Maybe this is a problem with my OL inst rather than your coding?

  40. #40
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Under no circumstances should there be a need to manually run
    the MMWatcher.exe program. That is why I added the code to
    make sure it was being launched from an Outlook menuitem.

    The watcher should only be started by the menuitems.

    Are you saying that in your Private Sub Application_Startup()
    procedure you have code to invoke the watcher? Do not do this.

    During the Outlook re-installion process the initialization of our
    custom menu items is not happening. You need to fix the issue
    with Outlook so everytime you start Outlook our menu items will
    get initialized. Basically, the Outlook macro issue is keeping the
    click event of our menu items from processing. They are just dead
    menu items when this happens.

    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

Page 1 of 2 12 LastLast

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