Trying to print preview before printing

Eric Penfold

Active Member
Joined
Nov 19, 2021
Messages
431
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
This is meant to find pdf then preview the pdf then print. It finds the Pdf fine but can`t work out how to fire up print preview.

VBA Code:
Public Sub PrintFile(strPdfFile As String)

           PdfFile.Expression.PrintPreview EnableChanges:=True
           ShellExecute Application.hwnd, "Print", strPdfFile, 0&, 0&, SW_HIDE
          

           End Sub

Private Sub Print_Drawing_Click()

Dim SourcePath As String
    Dim SubPath As String
    Dim PdfFile As String
    Dim MyPath As String
    Dim PDFFName As String
    Dim CmbData

        CmbData = Split(Me.pdfDrawingList.Value, "-")
        CmbData(0) = Replace(CmbData(0), "-", "")
        SourcePath = "\\dc01\Company\R&D\Drawing Nos"
       
     On Error GoTo ErrorHandling
       
    If Val(CmbData(0)) >= 10001 And Val(CmbData(0)) <= 10050 Then
        SubPath = "10001-10050"
    ElseIf Val(CmbData(0)) >= 10051 And Val(CmbData(0)) <= 10100 Then
        SubPath = "10051-10100"
    ElseIf Val(CmbData(0)) >= 10101 And Val(CmbData(0)) <= 10150 Then
        SubPath = "10101-10150"
    ElseIf Val(CmbData(0)) >= 10151 And Val(CmbData(0)) <= 10200 Then
        SubPath = "10151-10200"
    End If
       
        PDFFName = pdfDrawingList.Value
        PdfFile = SourcePath & "\" & SubPath & "\" & Int(CmbData(0)) & "\" & PDFFName
       
        Call PrintFile(PdfFile)
       
ErrorHandling:
     MsgBox "There is no PDF Drawing in Folder! Otherwise Specify what DrNo you Require"
       
        End Sub
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
.PrintPreview works with Excel workbooks. Maybe it'll do what you want.
 
Upvote 0
Based on responses so far I am guessing that this cannot be done. Just opening a PDF provides user with a "preview" of what would be printed if she tells the PDF reader to print.
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,184
Members
452,615
Latest member
bogeys2birdies

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