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

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
@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,224,828
Messages
6,181,209
Members
453,023
Latest member
alabaz

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