none
Using VBA Code behind a Custom Button to Export a Single Calendar Appointment Item RRS feed

  • Question

  • Hi All,

    My coding experience is limited and quite out-of-date now (I learned Borland C++ and COBOL back in 1993!)

    However, I would like to ask you all if it is possible to create a VBA Code Module for Outlook 2010, which can be used behind a Custom Button on the Ribbon/Toolbar that when clicked will use the provided VBA Code from the Brother B-PAC SDK to Print the Appointment Details on to a Label using a Brother QL-580N labelling Device. Info on the B-PAC SDK is here.. http://www.brother.com/product/dev/label/bpac/index.htm

    I have looked over the code samples supplied by Brother for Word, Excel and Access, but they do not include one for Outlook.

    My thoughts are that it should be possible to write a short peice of code that can use the APIs provided by Brother (in their SDK) to select the data from the active appointment and send it to the Labelling machine, as the Brother Code demonstrates that it can be done in Excel to choose a single Row and click a custom button to send the data in said row to the labelling machine.

    The Data is formatted by the Brother P-Touch Template held in the Networked QL-580N Labelling machine.

    It would really be appreciated if anybody could help me make a start with this little project as I have never coded for VBA before and I am unfamiliar with how to begin!

    Thanks all in advance for any responses.


    Richard

    Monday, August 27, 2012 1:59 PM

Answers

  • Ribbon customization can be done manually by right-clicking on the ribbon and then selecting customize for either the ribbon or quick action toolbar (QAT). In those customization dialogs you can select a Macro as the target of a button click.
     
    A skeleton macro would not take any arguments and would be public. It can go into any code module or the ThisOutlookSession class module. You would also need to enable the VBA project and macros.
     
    The currently selected appointment item would be accessed like this:
     
    Public Sub MyPrinterMacro()
        Dim oAppt As Outlook.AppointmentItem
        Set oAppt = Application.ActiveExplorer.Selection.Item(1)
    End Sub
     
    Once you have that reference you can access properties in the item and do your thing with the printer.
     
    See the areas at www.outlookcode.com for information on macros, Outlook VBA code, enabling the VBA project and macros, and how to access various properties in Outlook items.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "Archytype" <=?utf-8?B?QXJjaHl0eXBl?=> wrote in message news:21e9b392-3319-4925-9f4e-94196b4f5336...

    Hi All,

    My coding experience is limited and quite out-of-date now (I learned Borland C++ and COBOL back in 1993!)

    However, I would like to ask you all if it is possible to create a VBA Code Module for Outlook 2010, which can be used behind a Custom Button on the Ribbon/Toolbar that when clicked will use the provided VBA Code from the Brother B-PAC SDK to Print the Appointment Details on to a Label using a Brother QL-580N labelling Device. Info on the B-PAC SDK is here.. http://www.brother.com/product/dev/label/bpac/index.htm

    I have looked over the code samples supplied by Brother for Word, Excel and Access, but they do not include one for Outlook.

    My thoughts are that it should be possible to write a short peice of code that can use the APIs provided by Brother (in their SDK) to select the data from the active appointment and send it to the Labelling machine, as the Brother Code demonstrates that it can be done in Excel to choose a single Row and click a custom button to send the data in said row to the labelling machine.

    The Data is formatted by the Brother P-Touch Template held in the Networked QL-580N Labelling machine.

    It would really be appreciated if anybody could help me make a start with this little project as I have never coded for VBA before and I am unfamiliar with how to begin!

    Thanks all in advance for any responses.


    Richard


    Ken Slovak MVP - Outlook
    Monday, August 27, 2012 2:35 PM
    Moderator

All replies

  • Ribbon customization can be done manually by right-clicking on the ribbon and then selecting customize for either the ribbon or quick action toolbar (QAT). In those customization dialogs you can select a Macro as the target of a button click.
     
    A skeleton macro would not take any arguments and would be public. It can go into any code module or the ThisOutlookSession class module. You would also need to enable the VBA project and macros.
     
    The currently selected appointment item would be accessed like this:
     
    Public Sub MyPrinterMacro()
        Dim oAppt As Outlook.AppointmentItem
        Set oAppt = Application.ActiveExplorer.Selection.Item(1)
    End Sub
     
    Once you have that reference you can access properties in the item and do your thing with the printer.
     
    See the areas at www.outlookcode.com for information on macros, Outlook VBA code, enabling the VBA project and macros, and how to access various properties in Outlook items.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "Archytype" <=?utf-8?B?QXJjaHl0eXBl?=> wrote in message news:21e9b392-3319-4925-9f4e-94196b4f5336...

    Hi All,

    My coding experience is limited and quite out-of-date now (I learned Borland C++ and COBOL back in 1993!)

    However, I would like to ask you all if it is possible to create a VBA Code Module for Outlook 2010, which can be used behind a Custom Button on the Ribbon/Toolbar that when clicked will use the provided VBA Code from the Brother B-PAC SDK to Print the Appointment Details on to a Label using a Brother QL-580N labelling Device. Info on the B-PAC SDK is here.. http://www.brother.com/product/dev/label/bpac/index.htm

    I have looked over the code samples supplied by Brother for Word, Excel and Access, but they do not include one for Outlook.

    My thoughts are that it should be possible to write a short peice of code that can use the APIs provided by Brother (in their SDK) to select the data from the active appointment and send it to the Labelling machine, as the Brother Code demonstrates that it can be done in Excel to choose a single Row and click a custom button to send the data in said row to the labelling machine.

    The Data is formatted by the Brother P-Touch Template held in the Networked QL-580N Labelling machine.

    It would really be appreciated if anybody could help me make a start with this little project as I have never coded for VBA before and I am unfamiliar with how to begin!

    Thanks all in advance for any responses.


    Richard


    Ken Slovak MVP - Outlook
    Monday, August 27, 2012 2:35 PM
    Moderator
  • Hi Ken, that's very helpful, I shall checkout the site outlookcode.com.

    I see now from your example how I should begin going about this!

    I'll post up how i get on with this...

    Many Thanks,

    Richard


    Richard

    Monday, August 27, 2012 3:34 PM
  • No, check back in a week...

    Richard

    Tuesday, August 28, 2012 8:11 AM
  • Hi Archytype,

    Thanks for posting in the MSDN Forum.

    It's based on my experience that Ken's reply can solve your issue. I will mark it. Please feel free to unmark it if you feel it can solve your issue.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, September 4, 2012 6:48 AM
    Moderator