Multi User access to VB and VBA Program Settings Entries

Page 1 of 3 123 LastLast

  1. Posts : 20
    Windows 10
       #1

    Multi User access to VB and VBA Program Settings Entries


    Wnidows Ver: 20H2
    Excel Ver: MSO 16.0.14026.20202 (32-Bit)

    I have an Excel Addin which is installed under a user account with Admin privileges ( for registration of a COM assembly) using inno Setup. The installer also sets some VB and VBA Program Settings entries. My problem is that when Excel is opened under a different user account the VB and VBA Settings keys are not available. Where can I set registry key entries (via innoSetup) whch can then be accessed from various user accounts.
      My Computer

  2. Try3's Avatar
    Posts : 8,626
    Windows 10 Home x64 Version 21H1 Build 19043.1110
       #2

    Use a Registry Key within HKU or HKLM instead of HKCU.

    Denis
      My Computer


  3. Posts : 20
    Windows 10
    Thread Starter
       #3

    Multi User Access to VB and VBA Program Setting Entries


    I have created entries in the HKLM hive using innoSetup, but can't access these entries from code in the Open event of my Excel Addin. The attached file shows the code and the result of executing 2 different statements in the code. The Registry entry created by innoSetup is also shown.

    What is the correct VBA code to enable the key value created by innoSetup to be read?
    Multi User access to VB and VBA Program Settings Entries Attached Files
      My Computer

  4. Try3's Avatar
    Posts : 8,626
    Windows 10 Home x64 Version 21H1 Build 19043.1110
       #4
      My Computer

  5. Try3's Avatar
    Posts : 8,626
    Windows 10 Home x64 Version 21H1 Build 19043.1110
       #5

    1 Can you read that Registry Key yourself [RegEdit and/or Reg Query commands]?

    2 For advice on the VBA for reading the Registry, I suggest you use the last VBS Help file. It has good explanations & helpful examples.
    - VBS is relevant because you are using it within your VBA code.
    - You can download the last VBS Help file from Windows Scripting 5.6 Documentation by Ryan Farley
    - In the Help file, search for RegRead Method {you'll probably also want to have a look at RegWrite Method, RegDelete Method}
    - I cannot see anything wrong with your code snippets which is why I first suggested checking that you can read those Registry entries.

    3 Once you've posted those diagrams as diagrams in your post instead of within an attached file, you'll probably get others willing to help.

    Best of luck,
    Denis
      My Computer


  6. Posts : 20
    Windows 10
    Thread Starter
       #6

    Multi User Access to VB and VBA Program Setting Entries


    Hopefully this will provide diagrams in an acceptable manner:


    The following is the registry entry created by innosetup:

    Multi User access to VB and VBA Program Settings Entries-reg.png

    When Excel is launched the following is VBA code in the Open event of the Excel Addin

    Multi User access to VB and VBA Program Settings Entries-code1.png

    Executing the first msgbox statement produces this Error

    Multi User access to VB and VBA Program Settings Entries-err1.png

    Executing the second msgbox statement

    Multi User access to VB and VBA Program Settings Entries-code2.png

    produces this error

    Multi User access to VB and VBA Program Settings Entries-err2.png



    1. I have no problem reading the registry with RegEdit

    Thanks for your help.
      My Computer

  7. Try3's Avatar
    Posts : 8,626
    Windows 10 Home x64 Version 21H1 Build 19043.1110
       #7

    I still cannot see what is wrong with your code.

    You are able to access that key without using Admin permissions?
    - reg query would be a decent way of checking that
    Code:
    >REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender" /v PUAProtection
    HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender
        PUAProtection    REG_DWORD    0x0

    This code works and it matches your code
    Code:
    Sub RegReadTest()
    Dim WshShell As Object
    Set WshShell = CreateObject("WScript.Shell")
    ' The returned value is 0 because I have not enabled that facility
    MsgBox WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender\PUAProtection")
    End Sub
    Multi User access to VB and VBA Program Settings Entries-regread-example-hklm.png


    Denis
      My Computer


  8. Posts : 20
    Windows 10
    Thread Starter
       #8

    Multi User Access to VB and VBA Program Setting Entries


    1. reg query worked fine. It returned the correct value
    2. I am opening Excel with an Admin user a/c. I've opened Excel both under Admministrative Privileges and without Administrative privileges. The result is the same.
      My Computer

  9. Try3's Avatar
    Posts : 8,626
    Windows 10 Home x64 Version 21H1 Build 19043.1110
       #9

    Well, I'm not being any help to you at all.

    The only time I have seen a Registry access fault affecting user accounts in different ways was almost 10 years ago.
    - If the reg query test also works in the currently-VBA-failing user accounts then I really can't see Registry access being a cause.
    - The particular fault I recalled also affected access, in Excel's VBA Editor, to Tools, References and an immediate error dialog was shown when this was clicked on. The result was different for different user accounts so, if you are going to check this, you should do so in one of the currently-VBA-failing user accounts.

    I cannot see any significant difference between my VBA code and yours.
    - Your reg query test bowls out the chance that reading the FiskSim Registry Key is being hindered by Permissions on the Key.

    As a temporary workaround, perhaps you could return to the original Registry Key you started with before posting in TenForums [in HKCU, if I have understood you correctly] to recheck that and, if it still works, Export the Key then run the .reg file output within the user account of each other user.

    Denis
      My Computer


  10. Posts : 20
    Windows 10
    Thread Starter
       #10

    Multi User Access to VB and VBA Program Setting Entries


    Thanks again for your help. I don't know if this helps or hinders or even if its related. I've tried to to make the registry entry (via innoSetup) to the following HKEY_Users node:

    HKU\5-1-5-21-2176093051-1512646561-265167554-1001\SOFTWARE\FiskSim

    but innoSet failed with the following error:

    Multi User access to VB and VBA Program Settings Entries-hku.png
      My Computer


 
Page 1 of 3 123 LastLast

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd
All times are GMT -5. The time now is 11:58.
Find Us




Windows 10 Forums