I'm writing a macro which allows the user to insert a PDF into a worksheet. The trouble is that different people have different versions of Adobe. This code works on my machine:
ActiveSheet.OLEObjects.Add(ClassType:="Acrobat.Document.DC", Link:=False, DisplayAsIcon:=False).Activate
But that code will produce an error on someone else's machine because he needs this:
ActiveSheet.OLEObjects.Add(ClassType:="AcroExch.Document.DC", Link:=False, DisplayAsIcon:=False).Activate
Notice the ClassTypes are different. Is there a way to check if a ClassType exists? I'd like to do something like this:
If Exists(ClassType("Acrobat.Document.DC")) Then
ActiveSheet.OLEObjects.Add(ClassType:="Acrobat.Document.DC", Link:=False, DisplayAsIcon:=False).Activate
Else
ActiveSheet.OLEObjects.Add(ClassType:="AcroExch.Document.DC", Link:=False, DisplayAsIcon:=False).Activate
End If
Note: I can brute-force this by using On Resume Error Next, but that doesn't seem like the cleanest method.