VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

Create PDF from MS Access Report

Todd Benson  (3 Submissions)   Databases/Data Access/DAO/ADO   Visual Basic 3.0   Advanced   Wed 3rd February 2021

On a machine where the Adobe PDFWriter is installed, the current printer is swapped out with the PDFWriter and the PDF file is created. The original printer is then restored.

Inputs
rptName = Microsoft Access report name you want to create pdf from. sPDFPath = the directory path where you want to create the pdf file (ex. - "c:\data\"). sPDFName = the name of the pdf file you are wanting to create (ex. - "file001.pdf").

Assumes
This code is easily modified to be used in other programs

Side Effects
Please use the most recent installs of Adobe Exchange or PDFWriter to ensure proper functionality.

API Declarations
Declare Function RegEnumValue Lib "advapi32.dll" Alias "RegEnumValueA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpValueName As String, lpcbValueName As Long, ByVal lpReserved As Long, lpType As Long, ByVal lpData As String, lpcbData As Long) As Long
Declare Function RegOpenKeyEx Lib "advapi32" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
Declare Function RegSetValueEx Lib "advapi32" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal szData As String, ByVal cbData As Long) As Long
Declare Function RegCloseKey Lib "advapi32" (ByVal hKey As Long) As Long
Declare Function RegCreateKeyEx Lib "advapi32" Alias "RegCreateKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, lpSecurityAttributes As SECURITY_ATTRIBUTES, phkResult As Long, lpdwDisposition As Long) As Long
#If Win32 Then
Public Const HKEY_CLASSES_ROOT = &H80000000
Public Const HKEY_CURRENT_USER = &H80000001
Public Const HKEY_LOCAL_MACHINE = &H80000002
Public Const HKEY_USERS = &H80000003
Public Const KEY_ALL_ACCESS = &H3F
Public Const REG_OPTION_NON_VOLATILE = 0&
Public Const REG_CREATED_NEW_KEY = &H1
Public Const REG_OPENED_EXISTING_KEY = &H2
Public Const ERROR_SUCCESS = 0&
Public Const REG_SZ = (1)
#End If
Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Boolean
End Type

Rate Create PDF from MS Access Report (14(14 Vote))
Create PDF from MS Access Report.bas

Create PDF from MS Access Report Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters