Code:
Public Sub printDrawings()
Dim rng As Range, rCt As Long, r As Long, oExec
Set rng = ActiveSheet.Columns("B")
rCt = WorksheetFunction.CountA(rng) + 2
Set objWShell = CreateObject("Wscript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
For r = 2 To rCt
If ActiveSheet.Range("B" & r).Hyperlinks.Count > 0 Then
If InStr(1, ActiveSheet.Range("B" & r).Hyperlinks(1).Address, ".pdf", vbTextCompare) > 0 Then
Shell ("C:\Program Files(86x)\Adobe\Reader 10.0\Reader\AcroRd32.exe /t """ & ActiveSheet.Range("B" & r).Hyperlinks(1).Address & """ " & Application.ActivePrinter)
Else
Set oExec = objWShell.Exec("rundll32.exe shimgvw.dll,ImageView_PrintTo /pt """ & ActiveSheet.Range("B" & r).Hyperlinks(1).Address & """ " & Excel.ActivePrinter)
Do While oExec.Status = 0
Loop
' Clean up
Set oExec = Nothing
End If
End If
Next r
Set objWShell = Nothing
End Sub
Bookmarks