+ Reply to Thread
Results 1 to 8 of 8

LoadPicture for a ControlButton help

  1. #1
    Registered User
    Join Date
    04-06-2006
    Posts
    9

    LoadPicture for a ControlButton help

    Hello,

    I am writing a custom toolbar and I wish to assigne a picture to one of the control button but my syntax doesn't work. It bugs on .Picture=

    Could someone help ?


    Set cb = Application.CommandBars.Add(Name:="ToolBar1", temporary:=True)

    With cb
    Set cbpop = .Controls.Add(Type:=msoControlButton, temporary:=True)
    With cbpop
    .Picture = LoadPicture("C:\STOCK CONTROL\Data-Macro\ArrRedLeftPlain.bmp")
    .OnAction = ThisWorkbook.Name & "!Macro_Vide"
    End With
    End With

    Cheers
    Francois

  2. #2
    Tom Ogilvy
    Guest

    RE: LoadPicture for a ControlButton help

    What version of excel. I believe this is only supported in xl2003 (perhas
    2002).

    --
    Regards,
    Tom Ogilvy


    "micmacuk" wrote:

    >
    > Hello,
    >
    > I am writing a custom toolbar and I wish to assigne a picture to one of
    > the control button but my syntax doesn't work. It bugs on .Picture=
    >
    > Could someone help ?
    >
    >
    > Set cb = Application.CommandBars.Add(Name:="ToolBar1", temporary:=True)
    >
    >
    > With cb
    > Set cbpop = .Controls.Add(Type:=msoControlButton, temporary:=True)
    > With cbpop
    > .Picture = LoadPicture("C:\STOCK
    > CONTROL\Data-Macro\ArrRedLeftPlain.bmp")
    > .OnAction = ThisWorkbook.Name & "!Macro_Vide"
    > End With
    > End With
    >
    > Cheers
    > Francois
    >
    >
    > --
    > micmacuk
    > ------------------------------------------------------------------------
    > micmacuk's Profile: http://www.excelforum.com/member.php...o&userid=33253
    > View this thread: http://www.excelforum.com/showthread...hreadid=546771
    >
    >


  3. #3
    Registered User
    Join Date
    04-06-2006
    Posts
    9
    Thanks Tom,

    Am using Office 2000....so bad luck for me



    Quote Originally Posted by Tom Ogilvy
    What version of excel. I believe this is only supported in xl2003 (perhas
    2002).

    --
    Regards,
    Tom Ogilvy


    "micmacuk" wrote:

    >
    > Hello,
    >
    > I am writing a custom toolbar and I wish to assigne a picture to one of
    > the control button but my syntax doesn't work. It bugs on .Picture=
    >
    > Could someone help ?
    >
    >
    > Set cb = Application.CommandBars.Add(Name:="ToolBar1", temporary:=True)
    >
    >
    > With cb
    > Set cbpop = .Controls.Add(Type:=msoControlButton, temporary:=True)
    > With cbpop
    > .Picture = LoadPicture("C:\STOCK
    > CONTROL\Data-Macro\ArrRedLeftPlain.bmp")
    > .OnAction = ThisWorkbook.Name & "!Macro_Vide"
    > End With
    > End With
    >
    > Cheers
    > Francois
    >
    >
    > --
    > micmacuk
    > ------------------------------------------------------------------------
    > micmacuk's Profile: http://www.excelforum.com/member.php...o&userid=33253
    > View this thread: http://www.excelforum.com/showthread...hreadid=546771
    >
    >

  4. #4
    Registered User
    Join Date
    04-06-2006
    Posts
    9
    May be I could turn around this by creating a custom hiden toolbar with my custom buttom and copy them in the toolbar I want to use...
    But if so how could I copy those buttons in VBA ??

  5. #5
    Tom Ogilvy
    Guest

    Re: LoadPicture for a ControlButton help

    In xl2000 you would copy the picture to the clipboard and then use pasteface
    - so you migt have to import it into the worksheet first.

    --
    Regards,
    Tom Ogilvy


    "micmacuk" wrote:

    >
    > Thanks Tom,
    >
    > Am using Office 2000....so bad luck for me
    >
    >
    >
    > Tom Ogilvy Wrote:
    > > What version of excel. I believe this is only supported in xl2003
    > > (perhas
    > > 2002).
    > >
    > > --
    > > Regards,
    > > Tom Ogilvy
    > >
    > >
    > > "micmacuk" wrote:
    > >
    > > >
    > > > Hello,
    > > >
    > > > I am writing a custom toolbar and I wish to assigne a picture to one

    > > of
    > > > the control button but my syntax doesn't work. It bugs on .Picture=
    > > >
    > > > Could someone help ?
    > > >
    > > >
    > > > Set cb = Application.CommandBars.Add(Name:="ToolBar1",

    > > temporary:=True)
    > > >
    > > >
    > > > With cb
    > > > Set cbpop = .Controls.Add(Type:=msoControlButton, temporary:=True)
    > > > With cbpop
    > > > .Picture = LoadPicture("C:\STOCK
    > > > CONTROL\Data-Macro\ArrRedLeftPlain.bmp")
    > > > .OnAction = ThisWorkbook.Name & "!Macro_Vide"
    > > > End With
    > > > End With
    > > >
    > > > Cheers
    > > > Francois
    > > >
    > > >
    > > > --
    > > > micmacuk
    > > >

    > > ------------------------------------------------------------------------
    > > > micmacuk's Profile:

    > > http://www.excelforum.com/member.php...o&userid=33253
    > > > View this thread:

    > > http://www.excelforum.com/showthread...hreadid=546771
    > > >
    > > >

    >
    >
    > --
    > micmacuk
    > ------------------------------------------------------------------------
    > micmacuk's Profile: http://www.excelforum.com/member.php...o&userid=33253
    > View this thread: http://www.excelforum.com/showthread...hreadid=546771
    >
    >


  6. #6
    Tom Ogilvy
    Guest

    Re: LoadPicture for a ControlButton help

    Import into the worksheet, then copy it to the clipboard and use pasteface.

    --
    Regards,
    Tom Ogilvy


    "micmacuk" wrote:

    >
    > May be I could turn around this by creating a custom hiden toolbar with
    > my custom buttom and copy them in the toolbar I want to use...
    > But if so how could I copy those buttons in VBA ??
    >
    >
    > --
    > micmacuk
    > ------------------------------------------------------------------------
    > micmacuk's Profile: http://www.excelforum.com/member.php...o&userid=33253
    > View this thread: http://www.excelforum.com/showthread...hreadid=546771
    >
    >


  7. #7
    Registered User
    Join Date
    04-06-2006
    Posts
    9
    Thanks Tom it works...
    How can I give a "name" to the "shape" picture.

    I have paste my icon pic. on my data sheet and I have used the macro recorder to get the name of the pic. and was surprise to see the name ("Picture 4") although it is the only pic on this sheet.

    Also is there a way to copy the pic frpm the disk and paste it onto my data sheet (and then give it a name...) ?

  8. #8
    Tom Ogilvy
    Guest

    Re: LoadPicture for a ControlButton help

    turn on the macro recorder while you do

    Insert=>Picture from File

    I get
    ActiveSheet.Pictures.Insert( _
    "C:\Documents and Settings\OgilvyTW\My Documents\My
    Pictures\Part1.jpg").Select

    so to use that, some modifications:

    Dim Pic as Picture
    Dim sName as String
    sName = "C:\Myfiles\MyPictures\House.jpg"
    set pic = Activesheet.Pictures.Insert(sName)
    Pic.Name = "doghouse"

    --
    Regards,
    Tom Ogilvy

    "micmacuk" wrote:

    >
    > Thanks Tom it works...
    > How can I give a "name" to the "shape" picture.
    >
    > I have paste my icon pic. on my data sheet and I have used the macro
    > recorder to get the name of the pic. and was surprise to see the name
    > ("Picture 4") although it is the only pic on this sheet.
    >
    > Also is there a way to copy the pic frpm the disk and paste it onto my
    > data sheet (and then give it a name...) ?
    >
    >
    > --
    > micmacuk
    > ------------------------------------------------------------------------
    > micmacuk's Profile: http://www.excelforum.com/member.php...o&userid=33253
    > View this thread: http://www.excelforum.com/showthread...hreadid=546771
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1