I have an Excel workbook that uses VBA to create PDFs from sheets, and send them via email through Outlook.
When I click the button to create the PDFs and send, Microsoft Visual Basic gives me the follow error message:
Compile error: Can't find project or library
The debugger then highlights the following code:
Function Create_PDF_Sheet_Level_Names(NamedRange As String, FixedFilePathName As String, _
OverwriteIfFileExist As Boolean, OpenPDFAfterPublish As Boolean) As String
'This function will create a PDF with every sheet with
'a sheet level name variable <NamedRange> in it
Dim FileFormatstr As String
Dim Fname As Variant
Dim Ash As Worksheet
Dim sh As Worksheet
Dim ShArr() As String
Dim s As Long
Dim SheetLevelName As Name
'Test If the Microsoft Add-in is installed
If Dir(Environ("commonprogramfiles") & "\Microsoft Shared\OFFICE" _
& Format(Val(Application.Version), "00") & "\EXP_PDF.DLL") <> "" Then
...
In particular, the "Environ" in:
'Test If the Microsoft Add-in is installed
If Dir(Environ("commonprogramfiles") & "\Microsoft Shared\OFFICE" _
& Format(Val(Application.Version), "00") & "\EXP_PDF.DLL") <> "" Then
It should be able to find EXP_PDF.dll, as it does exist at:
C:\Program Files\Common Files\microsoft shared\OFFICE12\EXP_PDF.DLL
The user is using Office 2007, so the correct corresponding folder is OFFICE12.
I have attempted to run Regsvr32.exe in order to register the dll, but it doesn't work.
Best Answer
Here is a site with a solution for this problem