Trying to open a PDF in a folder

Eric Penfold

Active Member
Joined
Nov 19, 2021
Messages
424
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
This code finds the folder fine but the line below says run time error 13?
Can`t see any mismatch errors please help.

VBA Code:
SubPath = CStr(Val(Int(CmdData(0) / 50) * 50 + 1) & "-" & Int(CmdData(0) / 50 + 1) * 50"

Option Explicit
Public Sub OpenFile(strFilePath As String)
ShellExecute Application.Hwnd, "Open", strFilePath, 0&, 0&, SW_HIDE
End Sub
Private Sub Open_DrNo_Pdf_Click()

Dim SourcePath
Dim SubPath As String
Dim PdfPath As String
Dim CmdData
CmdData = Split(OpenDrawing.Value, "_")
CmdData(0) = Replace(CmdData(0), "_", "")
SourcePath = "\\dc01\Company\R&D\R & D Projects\Drawing Nos"
SubPath = CStr(Val(Int(CmdData(0) / 50) * 50 + 1) & "-" & Int(CmdData(0) / 50 + 1) * 50)
PdfPath = SourcePath & SubPath & "\" & Int(CmdData(0)) & "\" & OpenDrawing.Value & ".Pdf"
Call OpenFile(PdfPath)

End Sub
 
Sorry I am not trying to import data just open a Drawing PDF & also print it?
I have got the hyperlink function to work for Open the Drawing.
But struggling to print the PDF
 
Upvote 0

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Forum statistics

Threads
1,215,778
Messages
6,126,841
Members
449,343
Latest member
DEWS2031

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