Öncelikle merhabalar, bir excel dosyası üzerinde filtrelediğim PDF isimlerini kullanarak bunların URL sini bir sütuna yazdırıyorum, amacım bu URL leri kullanarak toplu bir şekilde çıktı almak. Tıkandığım nokta ise döng aşağıda yazan kod içinde
kısmında " Object variable or With block not set" hatası vermesi, 2 gündür arıyorum çözüm bulamadım.
Kod:
If Sh Is Nothing Then Set Sh = CreateObject("Shell.Application")
Kod:
Public Sub Print_PDFs()
Dim PDFsFolder As String
Dim PDFfile As String
Dim r As Long
PDFsFolder = "\\192.168.1.191\04-proje$\Teknik Resimler\Fkt Teknik Resimler\" 'CHANGE THIS
If Right(PDFsFolder, 1) <> "\" Then PDFsFolder = PDFsFolder & "\"
With Sheets("siparis")
For r = 2 To .Cells(.Rows.Count, "G").End(xlUp).Row
PDFfile = PDFsFolder & .Cells(r, "G").Value & ".pdf"
If PDFfile <> vbNullString Then
Print_PDF PDFsFolder & PDFfile
End If
Next
End With
End Sub
Private Sub Print_PDF(PDFfile As String)
Static Sh As Object 'Shell32.Shell
Dim folder As Variant, fileName As Variant
folder = Left(PDFfile, InStrRev(PDFfile, "\"))
fileName = Mid(PDFfile, InStrRev(PDFfile, "\") + 1)
If Sh Is Nothing Then Set Sh = CreateObject("Shell.Application")
Sh.Namespace(folder).Items.Item(fileName).InvokeVerb "Print"
End Sub