Consulting

Results 1 to 4 of 4

Thread: Printing a .pdf file

  1. #1

    Printing a .pdf file

    Hello

    I was wondering if someone could help me.

    I wanto print off a .pdf file as part of a dropdown variable but it doesn't seem to work

    Note: the file is already in .pdf so there is not need to convert from word before hand.

    I have a combobox on a userform that display the filename contents of a folder:

    This is the code for combobox

    [VBA]
    Private Sub UserForm_Initialize()
    'Files in folder listed in Listbox1
    Dim FSO As Object, fld As Object, Fil As Object
    Dim SubFolderName As String
    Dim i As Integer
    Set FSO = CreateObject("Scripting.FileSystemObject")
    Me.ComboBox1.Clear 'clear previous entries
    SubFolderName = "\\myserver\Documents"
    Set fld = FSO.GetFolder(SubFolderName)
    For Each Fil In fld.Files
    i = i + 1
    Me.ComboBox1.AddItem Fil.Name

    Next Fil
    End Sub
    [/VBA]

    the insert button is pressed along with other fields complete. What i want to do then is to open the ComboBox1 pdf file and print it off but it doesn't seem to work

  2. #2
    VBAX Regular sbrbot's Avatar
    Joined
    Aug 2008
    Location
    Zagreb, Croatia
    Posts
    13
    Location
    What? You want to open and print PDF document from VBA!? Can you open PDF document in Word? I don't think so. Hence, how could you do that in VBA?

  3. #3
    You can do this, but you need to hard-code the path to Acrobat.exe and re-write it if you install a different version:
    [vba]Shell ("""C:\Program Files\Adobe\Acrobat 8.0\Acrobat\Acrobat.exe"" /p /h ""C:\Temp\Document1.pdf""")[/vba]
    Also it will leave Acrobat open.

    Regards

  4. #4
    VBAX Regular sbrbot's Avatar
    Joined
    Aug 2008
    Location
    Zagreb, Croatia
    Posts
    13
    Location
    OK, this is calling external Adobe Acrobat to print this file, it is not printed from Word. However, for using this technique you can read Windows registry to find out what is the path to Acrobat Reader (in HKLM\SOFTWARE\Adobe\Acrobat Reader\9.0\InstallPath there is InstallPath key defining what is the path of Acrobat Reader, of course you cannot rely on that customer has 9.0 version of Reader) but I'm not sure if all this is needed. Finally you can offer customer a Browse button to select Acrobat Reader for printing docs. But as said at the beginning, Word does not work with PDF docs directly (at the moment, we'll se tommorow).

Posting Permissions

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