PrivateProfileString in Word 2013 RRS feed

  • Question

  • No matter what value I set my PrivateProfileString to, it returns True

    System.PrivateProfileString("", "HKEY_LOCAL_MACHINE\SOFTWARE\MyProgram", "License") = "Retail"

    When I check the registry for the value of License, it tells me the value is True.

    Same identical code worked perfectly in Word2003, 7 and 10.

    Any ideas?



    Thursday, February 14, 2013 11:44 PM

All replies

  • Hi Roy

    Have you checked to make sure that you've created a key with the correct data type: string, not boolean?

    I used PrivateProfileString the other day in Word 2013 and it did work as expected (returned the string value I requested).

    Cindy Meister, VSTO/Word MVP, my blog

    Friday, February 15, 2013 5:42 PM
  • As an alternative to the use of the SystemPrivateProfileString, try using the SaveSetting and GetSetting functions

    Doug Robbins - Word MVP dkr[atsymbol]mvps[dot]org

    Thursday, February 21, 2013 8:33 AM
  • Cindy,

    Thanks for the reply (and sorry for the long delay in offering thanks and responding).

    Unfortunately, I can duplicate on demand that there is a problem with the writing out of Private Profile Strings in Office 2013.

    After tweaking values and insuring the right Dims (all text now), I can consistently generate the error message:

    Run-time error '-2147467259(80004005)':
    Method 'PrivateProfileString' of object 'System' failed

    All works perfectly in all other settings (as it always had) with my tweaks.

    I am able to read the values of each of my PrivateProfileStrings but (and only in Office 2013/Windows8), I cannot write to them. (The above error now appears without fail when I am running in Office 2013/Office 365.)

    (As a practical matter, I am not losing any existing data in the registry. It's just that I cannot write to it. Always am getting error message.) I have no problem processing PrivateProfileStrings in Office2010 and prior, even on my Windows8 computer.

    Any thoughts?

    (I have over 200 settings in my PrivateProfile registry, so I would prefer not moving them all to the VB and VBA location with SaveSetting as Doug proposed. I have, however, just finished writing the code to do so and it works. But I have lots of users who may be adversely affected by such a change, so it is a 'last option' for me.)

    If Microsoft (or anyone who can help) wants to see this 'in action', let me know.

    Roy Lasris

    Tuesday, March 5, 2013 1:59 PM
  • Hi Roy

    It's possible that this is an issue with Windows 8 and that you may actually not have the necessary permissions to write in this part of the Registry. It might be worthwhile to check in a Windows 8 forum whether the Registry has been "sand-boxed", making it less accessible.

    The other possibility would be to change the PrivateProfileString to read/write to/from a *.ini file, as in the "good old days"...

    Cindy Meister, VSTO/Word MVP, my blog

    Friday, March 15, 2013 3:11 PM