Eric Penfold
Active Member
- Joined
- Nov 19, 2021
- Messages
- 431
- Office Version
- 365
- Platform
- Windows
- 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