Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2004

Tip: Looking for answers? Try searching our database.

Export registry string

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rene - 15 Nov 2004 12:14 GMT
Hi expert!

I need some help. I need to write a VBA macro that will export a
defined branch of the registry into a *.reg file.

Can anybody point me in the right direction?

Thanks,
Rene
Jean-Guy Marcil - 17 Nov 2004 03:41 GMT
Rene was telling us:
Rene nous racontait que :

> Hi expert!
>
> I need some help. I need to write a VBA macro that will export a
> defined branch of the registry into a *.reg file.
>
> Can anybody point me in the right direction?

You can read the registry from Word VBA, like

aName = System.PrivateProfileString("", _
   "HKEY_CURRENT_USER\Software\Microsoft\" _
   & "Windows\CurrentVersion\Internet Settings", "EmailName")
MsgBox aName

If you really want to export a key:

Set objShell = CreateObject("WScript.Shell")
objShell.Exec "regedit.exe /a C:\MyExport.reg " _
   & """HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run"""

Can you write a dll add-in and use VB or VB.Net?
See this VB example
http://www.freevbcode.com/ShowCode.Asp?ID=259

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Jay Freedman - 17 Nov 2004 16:00 GMT
> Rene was telling us:
> Rene nous racontait que :
[quoted text clipped - 23 lines]
> See this VB example
> http://www.freevbcode.com/ShowCode.Asp?ID=259

Very interesting... According to http://support.microsoft.com/kb/q168589/
the command-line switch for exporting from Regedit is /e rather than /a. I
tried both, on a Windows 2000 system, and both worked, in that they produced
files containing the same set of values. However, the one made with /a
starts with the line

REGEDIT4

while the one made with /e starts with the line

Windows Registry Editor Version 5.00

Version 5 of Regedit comes with Windows 2000 and later, while Version 4
shipped with Windows NT. I haven't tried importing the files to see whether
Regedit recognizes both equally well.

Signature

Regards,
Jay Freedman
Microsoft Word MVP          FAQ: http://word.mvps.org

Jean-Guy Marcil - 17 Nov 2004 16:29 GMT
Jay Freedman was telling us:
Jay Freedman nous racontait que :

>> Rene was telling us:
>> Rene nous racontait que :
[quoted text clipped - 30 lines]
> containing the same set of values. However, the one made with /a
> starts with the line

So I guess to be on the safe side, the "e" switch should be used!
Honestly, I did not know about all this until I read the poster's
question... 5 minutes later (well, maybe 10!) I was writing my answer
(Thanks to Google and an appropriate use of search words!). I did test it,
and it seemed to work although, like you, I did not try re-importing the reg
file... There are limits to what I will do to help a poster... Screwing
around with my registry is well beyond those limits!

Thanks for the info.

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org


Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.