Results 1 to 6 of 6

Thread: add button in excel

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2003
    Posts
    17

    add button in excel

    i need to use a visual basic program wich add a button in a excel and its script.


    I know to insert the button :

    ActiveSheet.OLEObjects.Add (classType:="Forms.CommandButton.1", Link:=False _
    , DisplayAsIcon:=False, Left:=izq, Top:=alto, Width:=60, Height:= _
    20.75).Select


    i need to know insert the script
    sub command1_click()
    end sub
    i dont know how?

    thx

  2. #2
    Fanatic Member davebat's Avatar
    Join Date
    Dec 2002
    Posts
    727
    in between the

    sub command1_click()
    and
    end sub

    type your script. I cant really make sense of what your asking so that is the only answer i can give. What are you trying to achieve

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jun 2003
    Posts
    17
    i need insert code of commandbutton using visual basic program,
    i'll open the work with the program the excel and i'll insert the button , but i don't know how insert the script of this button.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jun 2003
    Posts
    17
    i need insert code of commandbutton using visual basic program,
    i'll open excel with the program and i'll insert the button , but i don't know how insert the script of this button.

  5. #5
    Fanatic Member davebat's Avatar
    Join Date
    Dec 2002
    Posts
    727
    if its a macro youve created and assigned to abutton the code should already be there. Visual basic doesnt magiacally add code for you, so you will have to type it in using a keyboard

  6. #6
    Lively Member
    Join Date
    Jun 2003
    Location
    france
    Posts
    71
    i think the best way is not to creat the button but to hide it.

    I had the same problem, and in that case i used some code like

    if i need the button then commandbutton1.left = 42
    (i can see the button on my form)
    if i don't need the button then commandbutton1.left = 600
    (the button is not located on my form, i can't see it and reach it)

    like this you don't have to generate a new button with a new code each time you create a button

    you can also change the size of the userform using
    userform1.width or
    userform1.height

Posting Permissions

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



Click Here to Expand Forum to Full Width