Can a file printing routine be written not using the word "Shell32.dll" as using this within my protected VBA within an XLSB file is flagging that the Excel file contains a Trojan related script and is not able to email or download the excel file.
Existing code causing the Trojan error message.
Option Explicit
#If VBA7 Then
Private Declare PtrSafe 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
#Else
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
#End If
Public Const SW_HIDE = 0
Sub PrintFile(ByVal strFilePath As String)
Dim retVal As Long
retVal = ShellExecute(0, "Print", strFilePath, 0, 0, SW_HIDE)
If retVal < 32 Then
MsgBox "An error occured...Could not print"
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
End If
End Sub