Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2003
    Posts
    123

    Unanswered: Specify where PDF is saved

    In Access97, is there a way to specify where a report printed as a PDF file gets saved? I already have the report's Page Setup to default to the PDF "printer", but each time I still have to specify the folder I want it to go to. Is there a way in VBA to specify the same file directory to "print" to each time?

  2. #2
    Join Date
    Mar 2004
    Location
    Oakland, CA, USA
    Posts
    26

    RE: Specify where PDF is saved

    Hello jrn0074,

    Yes, you can. It depends on what OS you use. use VBA to write code to modify the registry or INI file every time you print to pdf. Hope it helps.

    for Win9x/ME: Append the entry PDFFileName=yourPath&FileName in Section [Acrobat PDFWriter] in "C:\WINDOWS\SYSTEM\pdfwritr.ini"

    for NT/2K/XP: Add the value PDFFileName to the key "HKEY_CURRENT_USER\Software\Adobe\Acrobat PDFWriter" with type is REG_SZ and data is yourPath&FileName.

    Below just for example, it's not a real code:
    '------------------
    Private Sub cmdPrint_Click()
    Dim myOS as string
    myOS = GetOS() 'write a procedure to get OS version
    If myOS = "Windows 2000" OR myOS = "Windows XP" then
    'write a procedure to modify the registry
    Else
    'write a procedure to append entry into the INI file.
    Endif
    DoCmd.OpenReport "myReport", acViewNormal
    End Sub
    '------------------
    Last edited by McCampbell; 10-22-04 at 01:00.

  3. #3
    Join Date
    Aug 2003
    Posts
    123

    Unhappy Specify where PDF is saved

    I'm not real knowledgable with editing INI's or the registry. But I'm on NT4 and the "HKEY_CURRENT_USER\Software\Adobe\Acrobat PDFWriter" key looks like the attached bitmap. I have no idea how to edit the registry from Access, and wouldn't I need to set it back to the original setting since I only want one specific report to do this?



    Quote Originally Posted by McCampbell
    Hello jrn0074,

    Yes you can. It depends on what OS you use. use VBA to write code to modify the registry or INI file every time you print to pdf. Hope it helps.

    for Win9x/ME: Append the entry PDFFileName=yourPath&FileName in Section [Acrobat PDFWriter] in "C:\WINDOWS\SYSTEM\pdfwritr.ini"

    for 2K/XP: Add the value PDFFileName to the key "HKEY_CURRENT_USER\Software\Adobe\Acrobat PDFWriter" with type is REG_SZ and data is yourPath&FileName.

    Below just for example, it's not a real code:
    '------------------
    Private Sub cmdPrint_Click()
    Dim myOS as string
    myOS = GetOS() 'write a procedure to get OS version
    If myOS = "Windows 2000" OR myOS = "Windows XP" then
    'write a procedure to modify the registry
    Else
    'write a procedure to append entry into the INI file.
    Endif
    DoCmd.OpenReport "myReport", acViewNormal
    End Sub
    '------------------

  4. #4
    Join Date
    Mar 2004
    Location
    Oakland, CA, USA
    Posts
    26

    RE: Modify registry

    Hello jrn0074,

    Don't worry about the entry or value PDFFileName in registry, it will be deleted automatically each time after you print to pdf so it won't effect with other reports. Bottom line, you must recreate this value prior to print to pdf each time. I believe you can use API function to modify the registry. I just do it in my way since it is short and easy to understand. Hope it will help this time.

    Note: This code for Win NT/2K/XP. If you have Antivirus software installed (Norton, etc.) then you must disable Script Blocking in order for VBS to execute.
    '------------------------------
    Private Sub cmdPrintPDF_Click()
    Dim runID As Variant
    Dim cmdLine As String, sysFolder As String, pathFile As String

    sysFolder = Environ("ComSpec")
    sysFolder = Left(sysFolder, Len(sysFolder) - 7)

    pathFile = "C:\mydata\pdf\report.pdf" '<---- Specify your path and file.

    Open sysFolder & "WriteReg.vbs" For Output As #1
    Print #1, "Set WshShell = WScript.CreateObject(""WScript.Shell"")"
    Print #1, "WshShell.RegWrite ""HKCU\Software\Adobe\Acrobat PDFWriter\PDFFileName"", """ & pathFile & """, ""REG_SZ"""
    Close #1

    cmdLine = sysFolder & "wscript.exe " & sysFolder & "WriteReg.vbs"
    runID = Shell(cmdLine, 0)

    DoCmd.OpenReport "myReport", acViewNormal

    End Sub
    '---------------------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •