Consulting

Results 1 to 8 of 8

Thread: Create Button Shadow Effect

  1. #1
    VBAX Mentor
    Joined
    Jan 2006
    Posts
    323
    Location

    Create Button Shadow Effect

    Hello, I am trying to create a shadow effect on a button I am creating using vba and have tried for hours with no success. Here are the two versions of code that I have been using to do this.

    If ActiveSheet.Name = "204 (2)" Then
            ActiveSheet.Buttons.Add(628, 48, 72, 26).Select
            Selection.Name = "Remove 204"
            Selection.Font.Bold = True
            Selection.OnAction = "Remove_204"
            ActiveSheet.Shapes("Remove 204").Select
            Selection.Characters.Text = "Remove 204"
           ' Selection.Shadow = True
    End If

        If ActiveSheet.Name = "204 (2)" Then
            Set btn = ActiveSheet.Buttons.Add(628, 48, 72, 26)
            With btn
                .OnAction = "Remove_204"
                .Caption = "Remove 204"
                .Font.Size = 11
                .Font.Bold = True
               ' .Shadow = True
            End With
        End If
    I can't figure it out using either method. Where have I gone wrong?

    Gary

  2. #2
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,642
    Sub M_snb()
      Sheet1.OLEObjects.Add("Forms.CommandButton.1", , , , , , , 200, 100, 100, 35).Shadow = True
    End Sub

  3. #3
    VBAX Mentor
    Joined
    Jan 2006
    Posts
    323
    Location
    With that I am now having trouble setting the other properties such as
    OnAction = "Remove_204"
    Caption = "Remove 204"
    Font.Size = 11
    Font.Bold = True

    Can you give me a push.

    Thanks


  4. #4
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,642
    Read the VBeditor helpfiles to get acquainted with the difference between ActiveX controls and formcontrols)

  5. #5
    VBAX Mentor
    Joined
    Jan 2006
    Posts
    323
    Location

    Done That - Didn't Help

    Quote Originally Posted by snb View Post
    Read the VBeditor helpfiles to get acquainted with the difference between ActiveX controls and formcontrols)

    I spent hours yesterday and today trying to figure it out using the help files and searching the net with no success. I would use the macro recorder but I can't find the "Assign Macro" function anywhere.

    Can you help me with this?

    thx
    Gary

  6. #6
    VBAX Mentor
    Joined
    Jan 2006
    Posts
    323
    Location
    So here is where i'm at. I have code in a Module that creates a new worksheet and also creates a button on that new worksheet. In the code I would like to have a shadow effect applied to the button and a macro assigned to the button. I have not been able to write code that will create the button shadow effect and assign a macro. I have only been able to create code that does one of the two requirements. In trying snb's code I am not able to assign a macro. I've been at this for two days and am very frustrated. Where am I going wrong?
    Please help.

  7. #7
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,642
    Start with:

    - creating a userform
    - adding a commdnbutton in that userform
    - adding code in the eventcode of that commandbutton.

    You will find lots of insttuctions to do that.

    If you create an ActiveX commandbutton in a worksheet, doubleclick it and you will be able to insert any code you like.

    If you do not understand these instruction: start with the basics in VBA first (e.g VBA for Dummies, written by J. Walkenbach)

  8. #8
    VBAX Mentor
    Joined
    Jan 2006
    Posts
    323
    Location
    snd, I'm not familiar with user forms so that's why I didn't try that. If a user form creates a pop up form, that is not what I was looking for. I was looking for a simple button with the shadow effect and macro assigned to it. Yes I could easily double click the commandbutton on the worksheet and add the code, but then what do the other users do after they press a different button to create the worksheet and are not familiar with VBA? If the button was to be permanent, I'm sure I would have figured it out by now but since the sheets are regularly created and deleted (by code I have written) I have not been able to do as previously discussed. I have been all over the net, through the excel help backwards and forwards, searched all over multiple bulletin boards (i'm sure far more in depth than VBA for dummies, but thanks for the advice) and have tried hundreds of code variations. I may not be a "Master" and not too familiar with user controls but I am familiar with VBA in general. I asked the question here because I couldn't figure it out and needed help. In my initial post I explain that I was looking for assistance in creating the shadow effect on the button after creating it. Your assistance led me to create the shadow effect but then prevented me from assigning a macro. I'm sure its a simple piece that I am missing, maybe not, nobody else chimed in with a solution, but again I wouldn't be here wasting your time if I could figure it out.

Posting Permissions

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