Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming VBA / September 2006

Tip: Looking for answers? Try searching our database.

Picture-Property outside an application not possible?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Peter Marchert - 28 Sep 2006 10:00 GMT
Hello together,

I want to load a own picture to an CommandBarButton outside the
application where it ist used. For example: I try to create a button in
word from excel vba. To do this I set a reference to word. Here ist the
code:

Sub Test()

   Dim objCommandBar       As Office.CommandBar
   Dim objButton           As Office.CommandBarButton
   Dim pic1                As stdole.IPictureDisp
   Dim msk1                As stdole.IPictureDisp

   Set pic1 = stdole.StdFunctions.LoadPicture("C:\pic1.bmp")
   Set msk1 = stdole.StdFunctions.LoadPicture("C:\msk1.bmp")

   Set objCommandBar = Word.Application.CommandBars.Add(Name:="TEST",
Temporary:=True)
   Set objButton = objCommandBar.Controls.Add(Type:=msoControlButton)

   With objButton
       .Style = msoButtonIcon
       .Picture = pic1
       .Mask = msk1
       .Caption = "Test"
   End With

   objCommandBar.Visible = True

End Sub

The code does not work. Only if the same code is placed in Word there
is no problem.

The faceId-Property I don`t want to use, because the same button is
used on another place
with a userdefined picture.

Is it not possible or is there a workarround?

Thanks for any help or suggestions!

Peter
Dmitry Streblechenko - 28 Sep 2006 17:55 GMT
IPicture cannot be marshalled across the process boundaries. You can copy a
bitmap to the clipboatrd and then call CommandBarButton.PasteFace.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool

> Hello together,
>
[quoted text clipped - 40 lines]
>
> Peter
Peter Marchert - 28 Sep 2006 20:35 GMT
Hello Dmitry :-)

thanks for your response - I will try the way you described.

Peter

Signature

Peter Marchert
EDV-Service Marchert
http://www.marchert.de

> IPicture cannot be marshalled across the process boundaries. You can copy
> a bitmap to the clipboatrd and then call CommandBarButton.PasteFace.
[quoted text clipped - 48 lines]
>>
>> Peter
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.