I am trying to run this macro to automatically print out a range of documents in a specified range but for some reason l am getting a an error - "Something went wrong". I have been told it is something to do with the path name not being correct. I cannot work out where in the coding the path name goes. I would appreciate it if someone could tell me where this goes in the coding:
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Private Const SW_SHOWNORMAL = 1
Public Sub PrintOneFile(fn As String)
Dim lngResult As Long
lngResult = ShellExecute(0&, "Print", fn, 0&, 0&, SW_SHOWNORMAL)
If lngResult <= 32 Then
MsgBox "Something went wrong.", vbExclamation
End If
End Sub
Sub PrintFiles()
Dim lngRow As Long
For lngRow = 747 To 758
PrintOneFile Range("J" & lngRow)
Next lngRow
End Sub
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Private Const SW_SHOWNORMAL = 1
Public Sub PrintOneFile(fn As String)
Dim lngResult As Long
lngResult = ShellExecute(0&, "Print", fn, 0&, 0&, SW_SHOWNORMAL)
If lngResult <= 32 Then
MsgBox "Something went wrong.", vbExclamation
End If
End Sub
Sub PrintFiles()
Dim lngRow As Long
For lngRow = 747 To 758
PrintOneFile Range("J" & lngRow)
Next lngRow
End Sub