Get list of users from .ini file

sharky12345

Well-known Member
Joined
Aug 5, 2010
Messages
3,421
Office Version
  1. 2016
Platform
  1. Windows
I am just starting to play around with CONFIG files so forgive me is this is relatively straightforward, but I have searched online and can't find anything that answers this question.

I am going to create a list of users and access levels but need to know how to retrieve them. This is what I have so far in my CONFIG file;

[USERS]
User=Steve
Access=Administrator
User2=James
Access2=Administrator
User3=John
Access3=Standard

Ideally, I would want each user added to a worksheet with their access level in another cell, (that way I can run a VBA routine to check what sheet they can view).

The part I am struggling with is do I look for the user and access level within the CONFIG file, (and therefore how do I do that), or is it better to import each user into the workbook and check their access that way, (and therefore how do I do that!).

Any help or advice would be appreciated.
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
.
If you are ok with not using an INI file, what about a Select Case approach ?

Code:
Option Explicit


Sub chkMacroaccess()
Dim strName As String


    strName = InputBox(Prompt:="Enter password please.", _
          Title:="ENTER YOUR PASSWORD")
        
        If strName = vbNullString Then
           


           Application.DisplayAlerts = False
           ThisWorkbook.Saved = True
           Application.Quit


        Else


          Select Case strName
           
            Case "krunk"
                MsgBox "This would be accessing your Macro [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=1]#1[/URL] " 'unhiding Sheet 2
            Case "logit"
                MsgBox "This would be accessing your Macro [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=2]#2[/URL] " 'unhiding Sheet 3
            Case "all"
                MsgBox "This would be accessing your Macro [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=3]#3[/URL] " 'unhiding all Sheets
            Case Else
                MsgBox "Sorry, wrong password."
                Exit Sub
          End Select


        End If


End Sub
 
Upvote 0
Thanks, your suggestion will actually help with another project which does not use a config file, but I really need to understand config files if possible so want to try an identify a solution for this using an .ini file.
 
Upvote 0
This is similar to,a post of yours end of December to which I replied can you not keep the threads together it will help others as well as yourself
 
Upvote 0

Forum statistics

Threads
1,223,268
Messages
6,171,099
Members
452,379
Latest member
IainTru

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top