Programatic VBA way of telling if the user has Word 2007 PDF add-ininstalled

S

Simon Jackson

Hi,


I'm trying to work out in VBA how to check to see if word has had the
Microsoft PDF add-in installed so that users can save documents as
PDF. I'd rather not just try and save a PDF and see if it errors,
there must be a better way.


I've tried iterating through the ComAddin's but it's not in that
collection.


Any pointers would be great.
 
G

Graham Mayor

You can test for the presence of the EXP_PDF.DLL e.g.

Sub CheckPDF()
Dim isOK as string
isOK = SpecFolder(CSIDL_PROGRAM_FILES_COMMON) & "\Microsoft
Shared\OFFICE12\EXP_PDF.DLL"
If Dir(isOK) <> "" Then
MsgBox "PDF Plug in is installed"
Else
MsgBox "PDF Plug in is not installed"
End IF
End Sub

You will of course need the function to locate the special folder.

Public Declare Function SHGetSpecialFolderLocation _
Lib "shell32" (ByVal hWnd As Long, _
ByVal nFolder As Long, ppidl As Long) As Long

Public Declare Function SHGetPathFromIDList _
Lib "shell32" Alias "SHGetPathFromIDListA" _
(ByVal Pidl As Long, ByVal pszPath As String) As Long

Public Declare Sub CoTaskMemFree Lib "ole32" (ByVal pvoid As Long)

Public Const CSIDL_PERSONAL = &H5
Public Const CSIDL_DESKTOPDIRECTORY = &H10
Public Const CSIDL_PROGRAM_FILES_COMMON = &H2B
Public Const MAX_PATH = 260
Public Const NOERROR = 0

Public Function SpecFolder(ByVal lngFolder As Long) As String
Dim lngPidlFound As Long
Dim lngFolderFound As Long
Dim lngPidl As Long
Dim strPath As String

strPath = Space(MAX_PATH)
lngPidlFound = SHGetSpecialFolderLocation(0, lngFolder, lngPidl)
If lngPidlFound = NOERROR Then
lngFolderFound = SHGetPathFromIDList(lngPidl, strPath)
If lngFolderFound Then
SpecFolder = Left$(strPath, _
InStr(1, strPath, vbNullChar) - 1)
End If
End If
CoTaskMemFree lngPidl
End Function



--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
S

Simon Jackson

Hi Graham,

That's just what I'm after,

Thank you very much for you help.

Kind regards
Simon Jackson
 

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