ASKER
ASKER
ASKER
ASKER
ASKER
MyCreateObject is optional keyword that can be used during declaration ...1.) OK, can you show me please the reference? In Object Browser or what ever you can find?
stay here :-)Okay.
ASKER
Your recommendation is to re-install .NET Framework...Yes, and as long as you make a backup first it can't hurt to try it.
ASKER
ASKER
Sub TestMerge2()
Dim MyPdf As Object
Set MyPdf = CreateObjectNET("Pmerge.dll", "Pmerge.Pmerge")
MyPdf.Add CurrentProject.Path & "\a.pdf"
MyPdf.Add CurrentProject.Path & "\b.pdf"
' set output file to merge above list to
MyPdf.OutPutDoc = CurrentProject.Path & "\ab.pdf"
'MyPdf.CreatePageNumbers = True
MyPdf.Merge ' merge the files
End Sub
Set MyPdf = CreateObjectNET("Pmerge.dll", "Pmerge.Pmerge")
4. The NetLoader Module code is below:Private Declare PtrSafe Function LoadLibrary Lib "kernel32" _
Alias "LoadLibraryA" (ByVal lpLibFileName As String) As LongPtr
#If Win64 Then
Private Declare PtrSafe Function MyCreateObject Lib "nloader64.dll" (ByVal strDll As String, ByVal strClass As String) As Object
#Else
Private Declare PtrSafe Function MyCreateObject Lib "nloader.dll" (ByVal strDll As String, ByVal strClass As String) As Object
#End If
'Private Function LoadLib(strDll As String) As Boolean
Dim s As String
Dim blRet As Boolean
Dim hLibDynaPDF As LongPtr
On Error Resume Next
LoadLib = False
hLibDynaPDF = LoadLibrary(CurrentProject.Path & "\" & strDll)
If hLibDynaPDF = 0 Then
' Our error string
s = "Sorry...cannot find the " & strDll & " file" & vbCrLf & _
"Please ensure that the " & strDll & " file is placed in the same folder as " & CurrentProject.Path
MsgBox s, vbOKOnly, "MISSING " & strDll & " FILE"
LoadLib = False
Exit Function
End If
' RETURN SUCCESS
LoadLib = True
End Function
Public Function CreateObjectNET(strDll As String, strClass As String) As Object
Static bIsLoaded As Boolean ' local static - for one time load
Dim loaderDLL As String ' use x64 or x32 .net loader
#If Win64 Then
loaderDLL = "nloader64.dll"
#Else
loaderDLL = "nloader.dll"
#End If
If bIsLoaded = False Then
If LoadLib(loaderDLL) = False Then
Set CreateObjectNET = Nothing
Exit Function
Else
bIsLoaded = True
End If
End If
Set CreateObjectNET = MyCreateObject(CurrentProject.Path & "\" & strDll, strClass)
End Function
5. The following line of code takes back the program control to Module1 Set CreateObjectNET = MyCreateObject(CurrentProject.Path & "\" & strDll, strClass)
Module1 codes starts to execute from: MyPdf.Add CurrentProject.Path & "\a.pdf"
MyPdf.Add CurrentProject.Path & "\b.pdf"
' set output file to merge above list to
MyPdf.OutPutDoc = CurrentProject.Path & "\ab.pdf"
'MyPdf.CreatePageNumbers = True
MyPdf.Merge ' merge the files
End Sub
I am getting Runtime Error 91 at the bolded line in Module1 code above. Private Declare PtrSafe Function LoadLibrary Lib "kernel32" _
Alias "LoadLibraryA" (ByVal lpLibFileName As String) As LongPtr
#If Win64 Then
Private Declare PtrSafe Function MyCreateObject Lib "nloader64.dll" (ByVal strDll As String, ByVal strClass As String) As Object
#Else
Private Declare PtrSafe Function MyCreateObject Lib "nloader.dll" (ByVal strDll As String, ByVal strClass As String) As Object
#End If
...
Dim hLibDynaPDF As LongPtr
LongPtr on Win32 is a long value while on 64 Bit a LongLong. It is not an own datatype than rather a Pointer, which can be converted by vba. LoadLibrary delivers a handle, but they are long values in 32 Bit environments.#If Win64 Then
Private Declare PtrSafe Function MyCreateObject Lib "nloader64.dll" (ByVal strDll As String, ByVal strClass As String) As Object
Private Declare PtrSafe Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As LongPtr
Dim hLibDynaPDF As LongPtr
#Else
Private Declare Function MyCreateObject Lib "nloader.dll" (ByVal strDll As String, ByVal strClass As String) As Object
Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
Dim hLibDynaPDF As Long
#End If
SeeI am getting Runtime Error 91 at the bolded line in Module1 code above.I would assume, also the PDF files are existing in the Project Path, right?
ASKER
Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
ASKER
The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.
TRUSTED BY