Can't figure out how to print a PDF file using VBA? Can anyone help please????

BrianG86

Board Regular
Joined
Nov 12, 2013
Messages
135
As stated, I cannot figure out how to print off PDF files using VBA.

I have a code that opens a folder and then is supposed to print off all pdf files in that folder.

Can anyone help me out?
 
As stated, I cannot figure out how to print off PDF files using VBA.

I have a code that opens a folder and then is supposed to print off all pdf files in that folder.

Can anyone help me out?

Maybe post the code you have and someone can try to see why it isn't working?
 
Upvote 0
This is my code so far, the next step for me is to print the file name that is in column A

Code:
Sub PDFPrint()    
Dim myShell As Object
Set myShell = CreateObject("WScript.Shell")
Dim wb As Workbook
Dim ws As Worksheet
Dim strF As String, strP As String
Dim strFP As String




Range("A2:A10000").ClearContents
    Set ws = ThisWorkbook.Sheets(1)
    strFP = Cells(1, 4).Value
    strP = "P:\17. PPI Packs\1. RBSO001 - RBS\" & strFP
    strF = Dir(strP & "\*.pdf")
    
    Do While strF <> vbNullString
       
       With ws
                If .Range("A1").End(xlDown).Row = 1048576 Then
                    .Range("A2").Value = strF
                Else
                    .Range("A" & Rows.Count).End(xlUp).Offset(1).Value = strF
                End If
            
        End With
        
    strF = Dir()
    
    Loop
    
End Sub
 
Upvote 0
Hi EdNerd, the code in the link isn't working for me.

Can anyone even tell me how I would open a pdf file?
 
Upvote 0
In what way doesn't the code in the link work? Do you get an error? (if so, what is it and where?)
 
Upvote 0
BriangG - please stick to one thread. Duplicates will be deleted. You'll get more help if you respond to the questions the people trying to help you are asking.
 
Upvote 0
this whole first part

Code:
[COLOR=#333333]Option Explicit[/COLOR]
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _ByVal hwnd As Long, _ByVal lpOperation As String, _ByVal lpFile As String, _ByVal lpParameters As String, _ByVal lpDirectory As String, _ByVal nShowCmd As Long) As Long </pre>[COLOR=#333333][/COLOR]


the error I am getting is
Compile Error:

The code in this project must be updated for use on 64 bit systems.
Please review and update Declare statements and then mark them with
the PtrSafe attribute.
 
Upvote 0
BriangG - please stick to one thread. Duplicates will be deleted. You'll get more help if you respond to the questions the people trying to help you are asking.

Starl,

I have replied to the people responding, have a look!

Also, I posted the other one yesterday and no-one responded so I worded it differently today and got responses!
 
Upvote 0

Forum statistics

Threads
1,226,839
Messages
6,193,267
Members
453,786
Latest member
ALMALV

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top