VBA-E: Unable to Print PDF

Solved
sifusalade Posted messages 142 Status Member -  
sifusalade Posted messages 142 Status Member -
Bonjour,

I would like to understand why I cannot print a PDF file with the code:

 Sub PrintFile(File As String) CreateObject("Shell.Application").Namespace(0).ParseName(File).InvokeVerb("Print") End Sub Sub test() Call PrintFile("D:\test.pdf") End Sub 


whereas for my test procedure, if I put this:
 Sub test() Call PrintFile("D:\test.png") End Sub 


or even
 Sub test() Call PrintFile("D:\test.docx") End Sub 


it works. I want to emphasize that all these test files are present, including the PDF.
I am using Excel 2010.

Do I need a specific PDF reader? I don’t have Acrobat Reader, is that the reason? I use Sumatra PDF Portable. But I tested by setting Edge as the default PDF reader, and it still doesn’t work, even with Edge. It’s strange that there are no issues with other types of files.

If anyone knows why, I would appreciate the information.

Thank you.

7 answers

  1. f894009 Posted messages 17417 Registration date   Status Member Last intervention   1 717
     
    Hello,
    At my place, it prints PDF file. Do you have an error?
    1
  2. The_boss_68 Posted messages 959 Registration date   Status Member Last intervention   182
     
    Hello,

    The code works for me too..... with Adobe Acrobat XI Pro

    Regards
    1
  3. The_boss_68 Posted messages 959 Registration date   Status Member Last intervention   182
     
    Good evening,

    Personally, I would say that a portable version does not install all the files where they need to be... so in the installed version, I'm pretty sure it would work, but that's just my opinion.

    Best regards
    1
  4. sifusalade Posted messages 142 Status Member 7
     
    Hello,

    It's very strange. Nothing is happening on my end. No error message. I even tried placing a MsgBox at the end of the test() procedure and that MsgBox displayed correctly. Only the PDF printing is not starting.
    0
  5. sifusalade Posted messages 142 Status Member 7
     
    Hello,

    Thank you. The more time goes by, the more I think that Acrobat Reader is essential.

    Is there a universal solution?
    0
    1. f894009 Posted messages 17417 Registration date   Status Member Last intervention   1 717
       
      Hi,

      What software do you use to open PDF files?
      0
  6. sifusalade Posted messages 142 Status Member 7
     
    With Sumatra PDF in portable version. But as I said, I also tried to set Edge as the default reader. But whether it's with Sumatra PDF or Edge, the printing doesn't start.
    0
  7. sifusalade Posted messages 142 Status Member 7
     
    Thank you. I thought the same thing. That's why I tried with Edge. Too bad, I will try to install Sumatra PDF. I don't like to install too many things on my computer. The less I have, the better it is. So as soon as I have portable versions, I take them. Too bad, I will install it and try again.

    I will come back to give the result of the test. Thank you.

    EDIT:
    I installed Sumatra PDF and it works now. This answers two questions:
    - Is Acrobat Reader absolutely necessary? Answer = No
    - Is it absolutely necessary to have a PDF reader installed? Answer = Yes, a portable version is not enough.
    0
    1. sifusalade Posted messages 142 Status Member 7
       
      Thank you to f894009 and The_Boss_68
      0