Results 1 to 5 of 5

Thread: [RESOLVED] Print pdf Adobe Microsoft Visual Basic.pdf

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    817

    Resolved [RESOLVED] Print pdf Adobe Microsoft Visual Basic.pdf

    I've asked this in a previous thread some time ago but hoping someone may have come up with a solution.

    If I print a VB document to the Adobe PDF print spooler the default filename that appears in the Save PDF File As dialog box is Microsoft Visual Basic.pdf

    I can get other PDF print spoolers to rename the output file by using this code but not the Adobe spooler. Does anyone know how this could be done?

    Code:
    Public Sub RenameJob(ByVal OldName As String, ByVal NewName As String)
          Dim vbPrinter As ApiPrinter
          Dim vbJob As ApiPrintJob
            Set vbPrinter = New ApiPrinter
            vbPrinter.DeviceName = Printer.DeviceName
            For Each vbJob In vbPrinter.PrintJobs
                  'If vbJob.DocumentName = OldName Then
                   vbJob.DocumentName = NewName
                    Exit For
                  'End If
            Next vbJob
    End Sub

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Print pdf Adobe Microsoft Visual Basic.pdf

    You might want to check out Adobes developers site. You just have to register to get limited access for free.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    817

    Re: Print pdf Adobe Microsoft Visual Basic.pdf

    Thanks RobDog888,

    I found this. And it's repeated a couple of times from uses asking the same question. Only problem is that it doesn't exactly say what key Vaue Name to add. I tried playing around manually creating a key in the Registry editor but it doesn't seem to do anything.

    Prompting can be turned off programmatically by modifying the
    Windows registry. This method applies to the creatiion of only one
    PDF document by a specific application for the current user. To do
    this, entries are added under the Windows Registry key:

    HKEY_CURRENT_USER\Software\Adobe\Adobe Distiller\PrinterJobControl

    This key takes as subkeys:
    (Default)
    application

    The (Default) entry is reserved for possible future use and should not
    be used. The application subkey is the full path of the application
    that is to have prompting turned off. The value of the application
    subkey is a REG_SZ value that is the full path of the output file. For
    example, the following registry script would turn off prompting for
    the next printing perform by wordpad.exe, printing to the file
    c:\MyPDFoutputFileName.pdf:

    Windows Registry Editor Version 5.00
    [HKEY_CURRENT_USER\Software\Adobe\Acrobat Distiller\PrinterJobControl]
    "C:\Program Files\Windows NT\Accessories\wordpad.exe" =
    "c:\MyPDFoutputFileName.pdf"

    Note: though the programming language may require that your
    backslashes are escaped (for example, "c:\\MyPDFoutputFileName.pdf"),
    the value of the registry entry must end up with just a single slash
    as shown above. The key, once established, remains until used and is
    removed once the Windows API function StartDoc (HDC hdc, CONST
    DOCINFO* lpdi) has successfully completed. Also note that the output
    folder path must already exist with read and write access for the
    current user and the destination file must not exist."

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    817

    Re: Print pdf Adobe Microsoft Visual Basic.pdf

    ok. I worked it out.

    The string key name needs to be the name my application (without quotation marks) and the value is the filename followed by an asterix (eg test.pdf*) or the full filename.




    Code:
    Public Function Registry_Read(Key_Path, Key_Name) As Variant
        On Error Resume Next
        Dim Registry As Object
        Set Registry = CreateObject("WScript.Shell")
        Registry_Read = Registry.RegRead(Key_Path & Key_Name)
    End Function
    Public Sub Registry_Write(Key_Path As String, Key_Name As String, Key_Value As Variant, Optional Key_Type As String)
        On Error Resume Next
        Dim Registry As Object
        Dim Registry_Value As Variant
        Set Registry = CreateObject("WScript.Shell")
        Registry_Value = Registry_Read(Key_Path, Key_Name)
        If Key_Type = "" Then
            'REG_SZ is the default.
            Registry.RegWrite Key_Path & Key_Name, Key_Value
        Else
            Registry.RegWrite Key_Path & Key_Name, Key_Value, Key_Type
        End If
    End Sub

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    817

    Re: Print pdf Adobe Microsoft Visual Basic.pdf

    Adobe version 5 was different apparently. There you had PDFWriter and if you created a registry key called "PDFFilename" in the [HKEY_CURRENT_USER\Software\Adobe\Acrobat PDFWriter] you could suppress the "Save As" dialog box. With PDFFilename you could put an * at the end of the string "C:\myfax.pdf*" to persist the setting (user never prompted to input a file name).

Posting Permissions

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



Click Here to Expand Forum to Full Width