+ Reply to Thread
Results 1 to 22 of 22

Floating Button

  1. #1
    Registered User
    Join Date
    12-17-2015
    Location
    Portland, OR
    MS-Off Ver
    Office 2010
    Posts
    26

    Floating Button

    I have created a box using the shapes icon and labeled it "Holds/Complaints" and attach it to a macro for a user form. I need the Holds/Complaints button to be floating in the exact same spot regardless of how much I scroll down or to the right. I have researched multiple threads on how to make this happen and it worked for them but for the life of me, I cannot get that button to float, so frustrating.

  2. #2
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Floating Button

    This will solve your problem...
    https://www.extendoffice.com/documen...nd-button.html

    Scroll down and select any cell...
    Attached Files Attached Files
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  3. #3
    Registered User
    Join Date
    12-17-2015
    Location
    Portland, OR
    MS-Off Ver
    Office 2010
    Posts
    26

    Re: Floating Button

    Only problem I have now is that the command button only stays if I am navigating through select the cell so the command button reappears. If I use the scroll bar then the command button does not stay.

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: Floating Button

    The cell part works better but still needs tweaking as to exact positioning the scrolling will require some more tweaking
    Attached Files Attached Files
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  5. #5
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: Floating Button

    I found this code on another form

    Please Login or Register  to view this content.
    If you remove the + oCell.Width the button will be on the selected cell

  6. #6
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Floating Button

    Perhaps making use of a userform containing command button...
    Set ShowModal property to false
    Attached Files Attached Files
    Last edited by Sintek; 12-14-2017 at 04:21 AM.

  7. #7
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: Floating Button

    Yes but the OP wants it to move with the selection
    Attached Files Attached Files

  8. #8
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Floating Button

    As per OP...Might be misinterpreting...
    I need the Holds/Complaints button to be floating in the exact same spot regardless of how much I scroll down or to the right.

  9. #9
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: Floating Button

    My mistake

  10. #10
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: Floating Button

    Minor modification so it works with 64 and 32 bit
    PtrSafe
    Attached Files Attached Files

  11. #11
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Floating Button

    If it's just a button, why not put it on the Ribbon?
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  12. #12
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: Floating Button

    Maybe because it won't 'Float'?
    It's a good idea, or even the QAT but then you would have to code it so it's available to all who use the file

  13. #13
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Floating Button

    I presume it only needs to "float" so it remains in view while scrolling, which a Ribbon button would do.

  14. #14
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,402

    Re: Floating Button

    .
    Here are several examples that may solve the issue :

  15. #15
    Registered User
    Join Date
    12-17-2015
    Location
    Portland, OR
    MS-Off Ver
    Office 2010
    Posts
    26

    Re: Floating Button

    Compile error.

    The code in this project must be updated for use on 64-bit systems.
    Please review and update Declare statements and then mark them with
    the PtrSafe attribute.

    Private Declare Function FindWindow Lib "user32" _
    Alias "FindWindowA" ( _
    ByVal lpClassName As String, _
    ByVal lpWindowName As String) As Long


    Private Declare Function GetWindowLong Lib "user32" _
    Alias "GetWindowLongA" ( _
    ByVal hWnd As Long, _
    ByVal nIndex As Long) As Long

    Private Declare Function SetWindowLong Lib "user32" _
    Alias "SetWindowLongA" ( _
    ByVal hWnd As Long, _
    ByVal nIndex As Long, _
    ByVal dwNewLong As Long) As Long

  16. #16
    Registered User
    Join Date
    12-17-2015
    Location
    Portland, OR
    MS-Off Ver
    Office 2010
    Posts
    26

    Re: Floating Button

    Thanks everyone for your responses in helping me, I appreciate your help. You all have helped me get started of what I'm sure my boss will be impressed.

    However, I want to send a Special Thanks to Logit. This person (boy or girl) helped out but beyond that he gave me some additional options of different macros that I didn't even think of, I really like the one where the command button appears 2 cells away from the cell that you have selected, super cool.

  17. #17
    Registered User
    Join Date
    12-17-2015
    Location
    Portland, OR
    MS-Off Ver
    Office 2010
    Posts
    26

    Re: Floating Button

    How do I get the commandbutton1 to appear on the left side of the cell that I have selected?

  18. #18
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,347

    Re: Floating Button

    in regard to the compile error if you are still having it
    find
    Please Login or Register  to view this content.
    and replace with

    Please Login or Register  to view this content.
    If you want something done right... find a forum and ask an online expert.

    Time flies like an arrow. Fruit flies like a banana.

  19. #19
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: Floating Button

    Write it like this to make if compatible with both 64 and 32 bit

    Please Login or Register  to view this content.

  20. #20
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Floating Button

    It takes more than just adding PtrSafe. For instance all the hWnd should be LongPtr and not Long, several of the functions should return LongPtr- and in fact be changed to call different functions- and corresponding variables in the code will also need to be altered.

  21. #21
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: Floating Button

    I beg to disagree, I've written quite some code and the #IF VBA7 .... #Else .... #End If declaring PtrSafe in the true section nevear cause dany issues and all ar set as Long
    The fact is that the #if VBA7 and PtrSafe interpret the As Long as a LongPtr

  22. #22
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Floating Button

    No it does not. A LongPtr resolves to either a Long or a LongLong depending on the bitness. Using a Long incorrectly may lead to your program terminating abruptly with no warning (at best).

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Floating Command Button
    By mitank in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-03-2017, 06:18 AM
  2. Floating Command Button
    By tapsmiled in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-27-2014, 08:36 PM
  3. Floating command button
    By Pat in forum Excel General
    Replies: 5
    Last Post: 08-31-2012, 03:49 PM
  4. Floating Control Button
    By RKleebaum in forum Excel - New Users/Basics
    Replies: 7
    Last Post: 04-05-2010, 11:41 AM
  5. Floating Command Button
    By GuruWannaB in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-07-2009, 04:50 PM
  6. Floating Button - Possible?
    By DCSwearingen in forum Excel General
    Replies: 1
    Last Post: 02-20-2007, 11:07 AM
  7. [SOLVED] Create floating button based on button click in menu
    By ExcelMonkey in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-12-2005, 02:05 PM

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