Getting Info From Registry VBA

P

Paul W Smith

Can any advise me what VBA code I use to extract contents of the following
registry key?

HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\Acrobat Reader\9.0\InstallPath

PWS
 
C

Chip Pearson

I have a module file that wraps up all the messy Windows API code into
nice neat and easy to use VBA functions. Download, unzip, and import
http://www.cpearson.com/Zips/modRegistry.zip. This will create a
module in your project named modRegistry.

It has functions for reading and writing registry keys and values as
well as a number of support functions. The specific function you want
to use is RegistryGetValue which returns an existing value from an
existing key. If the key or value is not found, the result is Null,
which is why the result is tested with IsNull and why RegVal must be a
Variant data type. For example,


Dim RegVal As Variant
RegVal = RegistryGetValue(HKLM, _
"SOFTWARE\Adobe\Acrobat Reader\9.0", "InstallPath")
If IsNull(RegVal) Then
Debug.Print "value not found"
Else
Debug.Print "value: " & CStr(RegVal)
End If


Cordially,
Chip Pearson
Microsoft MVP 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com
[email on web site]
 
W

Walter Briscoe

In message <[email protected]> of Sun, 3 Jan
2010 14:08:18 in microsoft.public.excel.programming, Chip Pearson
I have a module file that wraps up all the messy Windows API code into
nice neat and easy to use VBA functions. Download, unzip, and import
http://www.cpearson.com/Zips/modRegistry.zip. This will create a
module in your project named modRegistry.

That might allow me to do something I don't know how to do yet.

I find that loading some pages in Internet Explorer takes an
unreasonable time when pictures are involved.

In IE8, one can manually control whether pictures are loaded in future
activations with Tools/Internet Options/Advanced/Show pictures - it is
one of the Multimedia checkboxes.

MY ? I infer that changes a registry entry or entries. Which one(s)?

I want to implement the following pseudo-code
Switch off pictures
Set ie = CreateObject("InternetExplorer.Application") ' start ie
Switch on pictures.

I tried using Procmon to identify the relevant data. There was more
noise than I wanted to wander through.

BTW:
I normally access ie from VBA without opening an ie window.
This can be painful if ie decides to be slow about loading pictures.
I use this code:

Dim Fired As Boolean

....

Private Sub MakeIEVisible()
Fired = True
ie.Visible = True
End Sub

Sub foo()
Dim IEalarm As Date

...
IEalarm = Now + TimeValue("00:00:15")
Fired = False
Application.OnTime IEalarm, "MakeIEVisible"
Set ie = CreateObject("InternetExplorer.Application")
ie.Navigate2 URL1
Do While ie.busy Or ie.ReadyState <> 4: DoEvents: Loop
If Not Fired Then Application.OnTime IEalarm, "MakeIEVisible", schedule:=False
...
End Sub

Either the Internet access takes less than 15 seconds or an IE window is
opened, which allows me to use the "Esc" key to stop ie hanging about,
waiting for pictures I don't care about.
If I break that code in the debugger, IEAlarm is not called and the
schedule=False call fails. That is easily sorted by altering the next
statement to skip that call. There is probably a cleverer way to handle
running code in the debugger. This is clever enough for me. ;)
I could use onerror, but choose not to.
 
W

Walter Briscoe

In message <[email protected]> of Thu, 7 Jan 2010
16:16:10 in microsoft.public.excel.programming, Walter Briscoe
In message <[email protected]> of Sun, 3 Jan
2010 14:08:18 in microsoft.public.excel.programming, Chip Pearson


That might allow me to do something I don't know how to do yet.

I find that loading some pages in Internet Explorer takes an
unreasonable time when pictures are involved.

I managed to find the relevant entry. I find that its value is read
every time Navigate2 is used. I now use code like this:

Dim Do As Object
Dim IE as Object
Dim RegVal As Variant

Private Sub awaitIE()
Do Until Not IE.busy And IE.ReadyState = 4: DoEvents: Loop
End Sub

Private Sub TxURL(ByVal URL1 As String)
Dim RegOK As Boolean

If IE Is Nothing Then
RegVal = RegistryGetValue(HKCU, _
"Software\Microsoft\Internet Explorer\Main", _
"Display Inline Images")
If RegVal <> "no" Then RegOK = RegistryCreateValue(HKCU, _
"Software\Microsoft\Internet Explorer\Main", _
"Display Inline Images", "no")
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
End If

IE.Navigate2 URL1
awaitIE
Set Doc = IE.Document
End Sub

....
' I would like to have the following in an exit handler,
' but can't find that concept in VBA
Set IE = Nothing
If RegVal <> 0 And RegVal <> "no" _
Then RegOK = RegistryCreateValue(HKCU, _
"Software\Microsoft\Internet Explorer\Main", _
"Display Inline Images", RegVal)
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top