+ Reply to Thread
Results 1 to 3 of 3

Password character in InputBox

  1. #1
    Registered User
    Join Date
    11-11-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    54

    Question Password character in InputBox

    Hello everyone, I am trying to get user's passwords in a way so that they can enter it securely. One way is to simply create a form add a lable, add a textbox, and then a button, and then set the 'PasswordChar' property to "*", like such.
    Programming.png

    BUT, the problem, or lets say preferred way here is that I want all this to be in a single module, not two or three parts, just so it would make copying and pasting it later on easy, as easy as copying the whole project in a single go.

    At first I decided to construct the whole form, or input form, programmatically in the module itself, the problem with that solution is that it requires that some security settings should be changed so that it allows using VBProject to manipulate project objects from VB, which is not enjoyable, finally I found this solution on mrexcel.com:

    Please Login or Register  to view this content.
    Now the problem with this code is that in newer versions of office, on 64bit machines it says that it needs 'PtrSafe' to declare windows API functions and subs. Now when I use a

    Please Login or Register  to view this content.
    According to https://docs.microsoft.com/en-us/off...trsafe-keyword

    so the declration section has now become like this:

    Please Login or Register  to view this content.
    I am getting "Compile Error: Type Mismatch" error, when this line executes:
    Please Login or Register  to view this content.
    here is a sample workbook with the problematic section: Pass_Inbox.xlsm

    Now I am stuck and I don't know what to do. This code was just running fine on my somewhat older office, on my laptop, but when I brought it to company machine with office 2016 64bit, now it is not working because of type mismatch error. I don't know what to do, please help me with this pain in the neck problem I have exhausted all things I could think of and the reason why I am here. This is my ultimate final resort.
    Thank you www.excelforum.com!

  2. #2
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Password character in InputBox

    I think you need some LongPtr in there for 64 bit:

    Please Login or Register  to view this content.
    You can use the API viewer to get the correct declarations:

    https://www.rondebruin.nl/win/dennis...sapiviewer.htm

    WBD
    Office 365 on Windows 11, looking for rep!

  3. #3
    Registered User
    Join Date
    11-11-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    54

    Re: Password character in InputBox

    Quote Originally Posted by WideBoyDixon View Post
    I think you need some LongPtr in there for 64 bit:

    Please Login or Register  to view this content.
    You can use the API viewer to get the correct declarations:

    https://www.rondebruin.nl/win/dennis...sapiviewer.htm

    WBD
    Your solution worked like a charm. Thank you. Although I had to tweak the code a little bit, like adding some more LongPtrs. So here is the final code that is working.:

    Please Login or Register  to view this content.
    Because I don't have older offices like 2007, or 2010, I am not sure if this would work on older machines with excel 2007,2010, as well or not. Can you somehow confirm that it would work on older machines?

    By the way I have posted the final work on github too:
    https://github.com/dev0p0/View_Protected_Excel_Sheet

+ 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. Removing text after character from inputbox
    By chris.concise in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-01-2019, 02:11 PM
  2. [SOLVED] password inputbox
    By ColemanJames in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-08-2018, 01:47 PM
  3. [SOLVED] inputbox W/ password
    By keith740 in forum Excel General
    Replies: 3
    Last Post: 03-14-2017, 10:57 PM
  4. *** mask password in inputbox
    By Kvracing in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-14-2014, 07:55 PM
  5. [SOLVED] VBA InputBox Password Validation
    By mcmunoz in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 09-05-2013, 10:25 PM
  6. InputBox Password
    By noodle48 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-28-2011, 08:18 AM
  7. Msgbox if Inputbox entry contains character
    By Steph in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-23-2005, 01:05 PM

Tags for this Thread

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