Check if a pdf reader is installed on a pc

kelly mort

Well-known Member
Joined
Apr 10, 2017
Messages
2,169
Office Version
  1. 2016
Platform
  1. Windows
I have been searching the Web for solutions. I have seen a few examples of how to check if an Adobe Reader is installed but what I want is to be able to check if any pdf reader at all is installed.
This from excel forum:

I also came across this post on stack overflow:
Which is not VBA code though.

Can someone help me with how to use VBA to check if any pdf reader is installed?
Thanks in advance.
 
You could also do it like this:
VBA Code:
Public Function IsPDFReaderInstalled() As Boolean

    Dim oReg As Object
    Set oReg = CreateObject("WScript.Shell")
    
    On Error Resume Next
        oReg.RegRead "HKEY_CLASSES_ROOT\MIME\Database\Content Type\application/pdf\" & "CLSID"
                
    If Err.Number = 0 Then
        IsPDFReaderInstalled = True
        Exit Function
    Else
        'There's no default handler, is MS EDGE installed?
        Err.Clear
        On Error GoTo 0
        IsPDFReaderInstalled = IsEdgeInstalled
    End If

End Function

Function IsEdgeInstalled() As Boolean

    Dim temp As Object
    Dim rPath As String
    Dim keys()
    Dim key

    Set temp = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")

    rPath = "Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\PackageRepository\Packages"
    temp.EnumKey &H80000000, rPath, keys
    For Each key In keys
        If key Like "Microsoft.MicrosoftEdge*" Then
            IsEdgeInstalled = True
            Exit For
            Exit Function
        End If
    Next
    
End Function
 
Upvote 0

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
@Kyle123

I called the code like this:

Code:
Sub Test ()
     MsgBox IsPDFReaderInstalled
End Sub

And I get an error message:
Run-time error 92.
For loop not initiated.


On this line:

Code:
For Each key In keys
 
Upvote 0

Forum statistics

Threads
1,214,957
Messages
6,122,466
Members
449,086
Latest member
kwindels

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top