VB Code:
  1. Option Compare Database
  2.  
  3. Option Explicit
  4.  
  5.    Public Const REG_SZ As Long = 1
  6.    Public Const REG_DWORD As Long = 4
  7.  
  8.    Public Const HKEY_CLASSES_ROOT = &H80000000
  9.    Public Const HKEY_CURRENT_USER = &H80000001
  10.    Public Const HKEY_LOCAL_MACHINE = &H80000002
  11.    Public Const HKEY_USERS = &H80000003
  12.  
  13.    Public Const ERROR_NONE = 0
  14.    Public Const ERROR_BADDB = 1
  15.    Public Const ERROR_BADKEY = 2
  16.    Public Const ERROR_CANTOPEN = 3
  17.    Public Const ERROR_CANTREAD = 4
  18.    Public Const ERROR_CANTWRITE = 5
  19.    Public Const ERROR_OUTOFMEMORY = 6
  20.    Public Const ERROR_ARENA_TRASHED = 7
  21.    Public Const ERROR_ACCESS_DENIED = 8
  22.    Public Const ERROR_INVALID_PARAMETERS = 87
  23.    Public Const ERROR_NO_MORE_ITEMS = 259
  24.  
  25.    Public Const KEY_QUERY_VALUE = &H1
  26.    Public Const KEY_SET_VALUE = &H2
  27.    Public Const KEY_ALL_ACCESS = &H3F
  28.  
  29.    Public Const REG_OPTION_NON_VOLATILE = 0
  30.    
  31.    Private drexisting As aht_tagDeviceRec
  32.            Const AcrobatName = "FinePrint pdfFactory Pro"
  33.            'Const AcrobatName = "FinePrint pdfFactory"
  34.            Const AcrobatDriver = "PDFWRITR"
  35.            Const AcrobatPort = "LPT1:"
  36.  
  37.    Declare Function RegCloseKey Lib "advapi32.dll" _
  38.    (ByVal hKey As Long) As Long
  39.    Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias _
  40.    "RegCreateKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, _
  41.    ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions _
  42.    As Long, ByVal samDesired As Long, ByVal lpSecurityAttributes _
  43.    As Long, phkResult As Long, lpdwDisposition As Long) As Long
  44.    Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias _
  45.    "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, _
  46.    ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As _
  47.    Long) As Long
  48.    Declare Function RegQueryValueExString Lib "advapi32.dll" Alias _
  49.    "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As _
  50.    String, ByVal lpReserved As Long, lpType As Long, ByVal lpData _
  51.    As String, lpcbData As Long) As Long
  52.    Declare Function RegQueryValueExLong Lib "advapi32.dll" Alias _
  53.    "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As _
  54.    String, ByVal lpReserved As Long, lpType As Long, lpData As _
  55.    Long, lpcbData As Long) As Long
  56.    Declare Function RegQueryValueExNULL Lib "advapi32.dll" Alias _
  57.    "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As _
  58.    String, ByVal lpReserved As Long, lpType As Long, ByVal lpData _
  59.    As Long, lpcbData As Long) As Long
  60.    Declare Function RegSetValueExString Lib "advapi32.dll" Alias _
  61.    "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, _
  62.    ByVal Reserved As Long, ByVal dwType As Long, ByVal lpValue As _
  63.    String, ByVal cbData As Long) As Long
  64.    Declare Function RegSetValueExLong Lib "advapi32.dll" Alias _
  65.    "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, _
  66.    ByVal Reserved As Long, ByVal dwType As Long, lpValue As Long, _
  67.    ByVal cbData As Long) As Long
  68.    Global g_OpSys As String
  69.    Public Function SetValueEx(ByVal hKey As Long, sValueName As String, lType As Long, vValue As Variant) As Long
  70.        Dim lValue As Long
  71.        Dim sValue As String
  72.        Select Case lType
  73.            Case REG_SZ
  74.                sValue = vValue & Chr$(0)
  75.                SetValueEx = RegSetValueExString(hKey, sValueName, 0&, lType, sValue, Len(sValue))
  76.            Case REG_DWORD
  77.                lValue = vValue
  78.                SetValueEx = RegSetValueExLong(hKey, sValueName, 0&, lType, lValue, 4)
  79.            End Select
  80.    End Function
  81.    Function QueryValueEx(ByVal lhKey As Long, ByVal szValueName As _
  82.    String, vValue As Variant) As Long
  83.        Dim cch As Long
  84.        Dim lrc As Long
  85.        Dim lType As Long
  86.        Dim lValue As Long
  87.        Dim sValue As String
  88.  
  89.        On Error GoTo QueryValueExError
  90.  
  91.        ' Determine the size and type of data to be read
  92.        lrc = RegQueryValueExNULL(lhKey, szValueName, 0&, lType, 0&, cch)
  93.        If lrc <> ERROR_NONE Then Error 5
  94.  
  95.        Select Case lType
  96.            ' For strings
  97.            Case REG_SZ:
  98.                sValue = String(cch, 0)
  99.  
  100.    lrc = RegQueryValueExString(lhKey, szValueName, 0&, lType, sValue, cch)
  101.                If lrc = ERROR_NONE Then
  102.                    vValue = Left$(sValue, cch - 1)
  103.                Else
  104.                    vValue = Empty
  105.                End If
  106.            ' For DWORDS
  107.            Case REG_DWORD:
  108.    lrc = RegQueryValueExLong(lhKey, szValueName, 0&, lType, lValue, cch)
  109.                If lrc = ERROR_NONE Then vValue = lValue
  110.            Case Else
  111.                'all other data types not supported
  112.                lrc = -1
  113.        End Select
  114.  
  115. QueryValueExExit:
  116.        QueryValueEx = lrc
  117.        Exit Function
  118.  
  119. QueryValueExError:
  120.        Resume QueryValueExExit
  121.    End Function
  122. Public Sub SetKeyValue(sKeyName As String, sValueName As String, vValueSetting As Variant, lValueType As Long)
  123.        Dim lRetVal As Long         'result of the SetValueEx function
  124.        Dim hKey As Long            'handle of open key
  125.  
  126.        'open the specified key
  127.        lRetVal = RegOpenKeyEx(HKEY_CURRENT_USER, sKeyName, 0, KEY_SET_VALUE, hKey)
  128.        lRetVal = SetValueEx(hKey, sValueName, lValueType, vValueSetting)
  129.        RegCloseKey (hKey)
  130.    End Sub
  131.            Sub ResetDefaultPrinter()
  132.                    Call ahtSetDefaultPrinter(drexisting)
  133.            End Sub
  134.            Function ChangeToAcrobat()
  135.                If ahtGetDefaultPrinter(drexisting) Then
  136.                    Dim dr As aht_tagDeviceRec
  137.                    With dr
  138.                        .drDeviceName = AcrobatName
  139.                        .drDriverName = AcrobatDriver
  140.                        .drPort = AcrobatPort
  141.                    End With
  142.                    Call ahtSetDefaultPrinter(dr)
  143.               End If
  144.            End Function
  145.            Sub ChangePdfFileName(NewFileName As String)
  146.               Call aht_apiWriteProfileString("Acrobat PDFWriter", "PDFFileName", NewFileName)
  147.            End Sub
  148. Function SetupPdfForPrint(ByVal sReportFile As String, ByVal keyVal) 'FOR WINDOWS NT/2000 PDF PRINTING
  149. '- Updates the registry for the correct pdffilename
  150. '- also sets bExecViewer = 0 just in case
  151. '  (so the Acrobat program is not launched after the file is created)
  152.     'SetKeyValue "Software\Adobe\Acrobat PDFWriter", "bExecViewer", "0", REG_SZ
  153.     'SetKeyValue "Software\Adobe\Acrobat PDFWriter", "PDFFileName", sReportFile, REG_SZ
  154.     'SetKeyValue "Software\FinePrint Software\pdfFactory", "bExecViewer", "0", REG_SZ
  155.     'SetKeyValue "SOFTWARE\FinePrint Software\pdfFactory", "PDFFileName", sReportFile, REG_SZ
  156.     SetKeyValue "Software\FinePrint Software\pdfFactory\FinePrinters\FinePrint pdfFactory Pro\PrinterDriverData", "ShowDlg", keyVal, REG_DWORD
  157.     SetKeyValue "Software\FinePrint Software\pdfFactory", "OutputFile", sReportFile, REG_SZ
  158. End Function
  159. Function ResetKeyValue(ByVal keyVal)
  160. 'this function resets the dialog box that pops up for fine print
  161. 'pdf factory.  By reset we mean the dialog box does NOT come up
  162. 'if the key value is 0 the dialog box comes on
  163. 'if the key value is 4 the dialog box disappears
  164. SetKeyValue "Software\FinePrint Software\pdfFactory\FinePrinters\FinePrint pdfFactory Pro\PrinterDriverData", "ShowDlg", keyVal, REG_DWORD
  165. End Function
  166. Function GetOpSys()
  167.     GetOpSys = g_OpSys
  168.  End Function

VB Code:
  1. 'to print
  2. If Me.frameProjects.Value = 1 Then
  3.      'open issues report
  4.      rptName = "rptFOPL816"
  5.      ChangeToAcrobat 'MAKES pdf WRITER YOUR DEFAULT PRINTER
  6.      'second argument for key value.  0 turns on the dialog box
  7.      SetupPdfForPrint "FOPL816", 0
  8.      'ENTER TO PRINT 'THIS IS THE REPORT YOU WANT TO PRINT TO A PDF
  9.      
  10.      ResetDefaultPrinter 'RETURNS YOUR ORIGINAL PRINTER AS DEFAULT
  11.      ResetKeyValue 4     'reset the dialog box so it doesnt come on
  12.      Exit Sub
  13.   End If

Note this involves modifying the registry via code..since the default printer needs to be changed to the acrobat distiller. I used fineprint..but as you see in the comments this works for adobe as well.

Jon

P.S: CR 9.0 supports ADOBE PDF output..maybe its worth the update?