Consulting

Results 1 to 3 of 3

Thread: Solved: transparent command button vba

  1. #1
    VBAX Newbie
    Joined
    Jun 2009
    Posts
    2
    Location

    Solved: transparent command button vba

    When I create a command button manually and set it as transparent it is. But the code below does not make it transparent, even though the properties say it is.

    [vba]
    Private Sub Worksheet_Activate()

    Set obj = ActiveSheet.OLEObjects.Add(ClassType:="Forms.CommandButton.1", _
    Link:=False, DisplayAsIcon:=False, Left:=307, Top:=80, Width:=40, Height:=40)
    obj.Name = "CommandButton1"
    ActiveSheet.OLEObjects("CommandButton1").Object.BackStyle = fmBackStyleTransparent
    ActiveSheet.OLEObjects("CommandButton1").Object.Caption = ""

    End Sub
    [/vba]

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,875
    try:
    [vba]With ActiveSheet.OLEObjects.Add(ClassType:="Forms.CommandButton.1", _
    Link:=False, DisplayAsIcon:=False, Left:=307, Top:=80, Width:=40, Height:=40)
    .Name = "CommandButton1"
    .Object.BackStyle = fmBackStyleTransparent
    .Object.Caption = ""
    .ShapeRange.Fill.Transparency = 1#
    End With
    [/vba]
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    VBAX Newbie
    Joined
    Jun 2009
    Posts
    2
    Location
    Thanks very much, that's the one!

Posting Permissions

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