I am trying to create a code that could open a .pdf file via Adobe Acrobat by using Shell command method. However, i keep receiving an alert saying "Malicious Macro Detected" and my excel file shuts down itself without saving. After some debugging i realized it is the shell command that triggered the alert. May i know how to solve this?
Sub Link_Pdf_MQM()
Dim pageNo As String, filePath As String, myLink As String
Dim ThisButton As Object
Dim MachineNum As String
Set ThisButton = ActiveSheet.Shapes(Application.Caller)
Set ReferTable = Sheets("References").Range("MachineFilePath")
MachineNum = Split(ThisButton.TopLeftCell.Value, ":")(0)
filePath = ReferTable.Find(MachineNum, LookIn:=xlValues, lookat:=xlWhole).Offset(, 1).Value
pageNo = ThisButton.AlternativeText
Dim pat1 As String, pat2 As String, pat3 As String
pat1 = "C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe"
pat2 = " /A ""page=" & pageNo & "=Open Actions"" "
pat3 = filePath
myLink = pat1 & " /A ""page=" & pageNo & """ """ & pat3 & """"
Shell myLink, vbNormalFocus
End Sub
Sub Link_Pdf_MQM()
Dim pageNo As String, filePath As String, myLink As String
Dim ThisButton As Object
Dim MachineNum As String
Set ThisButton = ActiveSheet.Shapes(Application.Caller)
Set ReferTable = Sheets("References").Range("MachineFilePath")
MachineNum = Split(ThisButton.TopLeftCell.Value, ":")(0)
filePath = ReferTable.Find(MachineNum, LookIn:=xlValues, lookat:=xlWhole).Offset(, 1).Value
pageNo = ThisButton.AlternativeText
Dim pat1 As String, pat2 As String, pat3 As String
pat1 = "C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe"
pat2 = " /A ""page=" & pageNo & "=Open Actions"" "
pat3 = filePath
myLink = pat1 & " /A ""page=" & pageNo & """ """ & pat3 & """"
Shell myLink, vbNormalFocus
End Sub