+ Reply to Thread
Results 1 to 14 of 14

Unable to add OK/No button to existing Msg Box.

  1. #1
    Forum Contributor
    Join Date
    09-16-2014
    Location
    Hyderabad
    MS-Off Ver
    MS Office 2021
    Posts
    346

    Post Unable to add OK/No button to existing Msg Box.

    Hi! Everyone

    I have this customized welcome message in Excel 2010 and I would like to add Ok and Cancel button with a message "Do you wish to Continue?" below my customized message.

    If Ok, then enter the workbook and if Cancel then close the workbook.

    Please Login or Register  to view this content.
    Any help would be grateful. Thanks in anticipation to all.
    Last edited by Ravana; 09-21-2014 at 02:47 AM.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: How to add OK/No button to existing Msg Box

    Hi, Ravana,

    welcome to ExcelForum. Please have a look at Forum Rule #3 and wrap your procedure with code-tags as requested there.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Unable to add OK/No button to existing Msg Box.

    Hi, Ravana,

    maybe like this:
    Please Login or Register  to view this content.
    So any non authorized personal will choose no - I pretty much doubt that and I would build on Environ("Username") and a lookup table for allowance or a folder where entry is restricted by Operating System.

    Ciao,
    Holger

  4. #4
    Forum Contributor
    Join Date
    09-16-2014
    Location
    Hyderabad
    MS-Off Ver
    MS Office 2021
    Posts
    346

    Re: Unable to add OK/No button to existing Msg Box.

    Hello Holger,

    Thanks for the prompt reply. However there is no message box being displayed using the code you have replied.

    I am a novice to vb and hardly know any basics of vb. So I am relying on this forum to meet my needs.

    Hope, Sure forum helps me.

  5. #5
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Unable to add OK/No button to existing Msg Box.

    Hi, Ravana,

    you asked to add a yes-no button to the code not to make it work: any action for the button will only be valid from 19:00 to 23:59 per day as you check the current time where hour should be greater than 18.

    Ciao,
    Holger

  6. #6
    Forum Contributor
    Join Date
    09-16-2014
    Location
    Hyderabad
    MS-Off Ver
    MS Office 2021
    Posts
    346

    Re: Unable to add OK/No button to existing Msg Box.

    Hi Holger,

    Sorry if I wasn't clear about what I needed. Let me explain it to you.

    I want a display message stating time and date when it is being opened.Then in the next line Good Morning/Good Afternoon/Good Evening/Good Night depending upon the time of opening the file.

    And then in next line something like Welcome Mr./Mrs. "System User" to the "current workbook name" (without extension).

    Thereafter a Custom disclaimer message and below that "Do You Wish to Continue?" and below a 'OK' and 'No' buttons which work. If pressed Ok then user can enter the workbook. If No, then workbook closes.

    Hope I made myself clear.

    Can you help me out with this.

    Thanks in anticipation.

  7. #7
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Unable to add OK/No button to existing Msg Box.

    Hi, Ravana,

    using a MsgBox iot will be impossible to feature OK and No as this combinartion isnīt available there (either OK and CANCEL or YES and NO). Or you build your own UserForm to feature this combination.

    You might adapt the times for the messages:
    Please Login or Register  to view this content.
    Still not authorized personal may enter the workbook for authorized personal only if they click OK...

    Ciao,
    Holger

  8. #8
    Forum Contributor
    Join Date
    09-16-2014
    Location
    Hyderabad
    MS-Off Ver
    MS Office 2021
    Posts
    346

    Re: Unable to add OK/No button to existing Msg Box.

    Hi Holger,

    This will do for me. Thanks a ton..!!

  9. #9
    Forum Contributor
    Join Date
    09-16-2014
    Location
    Hyderabad
    MS-Off Ver
    MS Office 2021
    Posts
    346

    Re: Unable to add OK/No button to existing Msg Box.

    Hi Holger,


    As u said "Still not authorized personal may enter the workbook for authorized personal only if they click OK..." - is there anyway that if I click on Yes then it shall direct to another box asking for password. Is this possible?

    Thanks in anticipation.

  10. #10
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Unable to add OK/No button to existing Msg Box.

    Hi, Ravanna,

    sure but using an InputBox will not mask the password when entered, and you would need to protect the VBA-project to make it harder to view the password. I suggest you have a look at at using UserForm where you may mask the entry to a textbox instead of working with API for an InputBox.

    Please Login or Register  to view this content.
    Please note that you would have to swap the Select Case for the time entries in order to get a different message than Good Monring.

    Ciao,
    Holger

  11. #11
    Forum Contributor
    Join Date
    09-16-2014
    Location
    Hyderabad
    MS-Off Ver
    MS Office 2021
    Posts
    346

    Re: Unable to add OK/No button to existing Msg Box.

    Heah Holger !

    Thanks for being so generous and taking time to reply me. Your codes work fine always. This helped.

    As I said I am a very very beginner to vb, I don't know how to use any user forms. I just search the net and find help for the codes I needed time and again. As you said password can't be masked using it in this way, is there a workaround to mask the password? If so can you help me out?

    Thanks a ton !

  12. #12
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Unable to add OK/No button to existing Msg Box.

    Hi, Ravana,

    Quote Originally Posted by Post #10
    ... instead of working with API for an InputBox.
    Since you claim to be new to VBA please believe me that the easier way is to use a UserForm in VBA.

    Ciao,
    Holger

  13. #13
    Forum Contributor
    Join Date
    09-16-2014
    Location
    Hyderabad
    MS-Off Ver
    MS Office 2021
    Posts
    346

    Re: Unable to add OK/No button to existing Msg Box.

    Heah Holger,

    How to use UserForm to achieve my purpose i.e. to get all the display message as well password box with masking?

  14. #14
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Unable to add OK/No button to existing Msg Box.

    Hi, Ravana,

    code in ThisWorkbook:
    Please Login or Register  to view this content.
    Code behind frmPassword:
    Please Login or Register  to view this content.
    Ciao,
    Hoilger
    Attached Files Attached Files

+ 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. [SOLVED] Using VBA to add 1 to an existing value when button is clicked
    By mdovey in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-02-2014, 06:38 PM
  2. [SOLVED] Userform Button to Add Data to an Existing Table
    By abysva in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-20-2012, 09:36 AM
  3. How can i add a button to existing ribbon
    By J.wills in forum Outlook Programming / VBA / Macros
    Replies: 1
    Last Post: 03-30-2009, 02:41 AM
  4. Check Existing Button
    By Mike in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-27-2005, 01:05 PM
  5. Adding Code to an Existing Command Button with VBA
    By jasoncw in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-17-2005, 11:36 AM

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