Results 1 to 5 of 5
  1. #1
    4 Star Lounger
    Join Date
    Aug 2003
    Location
    Stroud, United Kingdom
    Posts
    548
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Commandbutton.Picture from outside App. (2003)

    Hi, i have seen from a Google that the following code in VB6 which is part of a custom install, publish and set up of a Form for Outlook (below is the 'add toolbar button' bit) will not work. The IPictureDisp object apparently cannot be used from outside the VBA when it comes to the .Picture and .Mask method.

    Guess what my question is... <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>
    Yes, is there ANY WAY to programmatically add an icon image to a newly created toolbar button from outside Outlook ? I am not so hopeful, i know there is an 'addin' method documented by MS, I suppose it would be possible to make this add-in, then 'add it' via the VB6 and run it so that it does what i want.

    Alternatively, i may have to just leave it with text, or a default image.... and I spent all that time making my icon and mask!! Oh well...

    Dim picon As stdole.IPictureDisp, pmask As stdole.IPictureDisp
    Set pIcon = stdole.StdFunctions.LoadPicture("C:OutlookFormsIma ge.bmp")
    Set pMask = stdole.StdFunctions.LoadPicture("C:OutlookFormsMas k.bmp")
    ' add the button
    Set cmdbt = cb.Controls.Add(1) ' msoControlButton
    With cmdbt
    .Caption = "button1"
    .BeginGroup = True
    .HyperlinkType = 1 ' msoCommandBarButtonHyperlinkOpen
    .ToolTipText = ' hyperlink here
    .Style = 3 ' textandIcon
    .Picture = pIcon
    .Mask = pMask
    .Visible = True
    End With
    Thanks,

    pmatz

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Commandbutton.Picture from outside App. (2003)

    The following code (based on the built-in help) works for me in Outlook 2002:

    Sub Test()
    Dim cbr As CommandBar
    Dim cbb As CommandBarButton
    Dim picPicture As IPictureDisp
    Dim picMask As IPictureDisp
    Set cbr = ActiveExplorer.CommandBars.Add("Test", , , True)
    cbr.Visible = True
    Set cbb = cbr.Controls.Add(msoControlButton, , , , True)
    Set picPicture = stdole.StdFunctions.LoadPicture("c:imagespicture.b mp")
    Set picMask = stdole.StdFunctions.LoadPicture("c:imagesmask.bmp" )
    With cbb
    'Set the style
    .Style = msoButtonIcon
    'Set the button image.
    .Picture = picPicture
    'Set the mask.
    .Mask = picMask
    End With
    Set picMask = Nothing
    Set picPicture = Nothing
    Set cbb = Nothing
    Set cbr = Nothing
    End Sub

  4. #3
    4 Star Lounger
    Join Date
    Aug 2003
    Location
    Stroud, United Kingdom
    Posts
    548
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Commandbutton.Picture from outside App. (2003)

    Sorry, I didnt make myself clear I dont think. I am running the code from VB6, in an exe file. In this sense it is outside the Outlook Application. I can manipulate everything apart from the .Picture and .Mask methods.
    Thanks,

    pmatz

  5. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Commandbutton.Picture from outside App. (2003)

    Sorry, can't help then.

  6. #5
    4 Star Lounger
    Join Date
    Aug 2003
    Location
    Stroud, United Kingdom
    Posts
    548
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Commandbutton.Picture from outside App. (2003)

    No worries, I think the amount of work is not worth it just for a custom icon [img]/forums/images/smilies/wink.gif[/img]

    Settled for

    cmdbt.FaceID = 2687

    which gives an appropriate icon that my manager is happy with [img]/forums/images/smilies/wink.gif[/img]

    have a good weekend Hans
    Thanks,

    pmatz

Posting Permissions

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