Write to registry problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi folks,

I used the following code to read and write a value from and to registry in
Access 2002. But it put the value to “HKeys_Users\...\VB and VBA Program
Settings\â€. Could anyone tell me how to fix it?

Thanks in advance.

Tim.

SaveSetting "HKEY_CURRENT_USER\Software\Adobe", "Acrobat PDFWriter",
"bExecViewer", 0
Debug.Print GetSetting(appname:="Adobe", Section:="Acrobat PDFWriter", _
Key:="bExecViewer", Default:=0)
 
Tim said:
Hi folks,

I used the following code to read and write a value from and to
registry in Access 2002. But it put the value to "HKeys_Users\...\VB
and VBA Program Settings\". Could anyone tell me how to fix it?

Thanks in advance.

Tim.

SaveSetting "HKEY_CURRENT_USER\Software\Adobe", "Acrobat PDFWriter",
"bExecViewer", 0
Debug.Print GetSetting(appname:="Adobe", Section:="Acrobat
PDFWriter", _ Key:="bExecViewer", Default:=0)

The built-in SaveSetting and GetSetting functions always write and read
from a particular subtree. as you've noted. If you want to work with a
different part of the registry, you can probably adapt Karl Peterson's
VB code posted here:

http://vb.mvps.org/samples/project.asp?id=RegSettings
 
Hi Dirk,

Thanks for your quick respone. But I don't have VB install in my system. I
can't view the code. Do you have some code write in VBA?

Thanks in advance.

Tim.
 
His class module is near as dammit to VBA. Just delete the first few
"VB ish" lines, the rest will probably be AOK.

Remember that microsoft are tightening up on where you can write in the
registry. For example, HKLM/Software/<company>/<product> used to be
fine, but in windows xp and later, you can't write there fom a
non-Administrative account, unless you change the default permissions
on that key.

HTH,
TC [MVP Access]
 
Hi TC,

I imported the file to my database. When I compiled the module, I got error
message “variable not define†and “App†was highlighted. Could you help me
to fix it?

Thanks for your time.

Tim.
 
Tim said:
Hi TC,

I imported the file to my database. When I compiled the module, I
got error message "variable not define" and "App" was highlighted.
Could you help me to fix it?

"App" is a built-in object in the full Visual Basic environment that
isn't available in VBA. Looking at the class object code, I see that
its only use is to provide the ProductName to a public property of the
class. I'd suggest you replace that with

CurrentDb.Properties("AppTitle")

Or else hard-code the value you want to use. Note, that the AppTitle
property will only have been created if you entered it in the database's
Tools -> Startup... dialog, and referring to it if it hasn't been
created will cause an error. So you'll probably want to use a little
error-handling code surrounding any reference to it.
 
Dirk,

Thanks for your response. I still can't get it even I follow your
direction.

Thank you for your time and help.

Tim.
 
Tim said:
Dirk,

Thanks for your response. I still can't get it even I follow your
direction.

So what have you got? If you post the code you're using and tell what
errors you're getting, we can probably figure out how to fix it.
 
Back
Top