Malicious Macro Detected When Using Shell Command

CK Zhien

New Member
Joined
Jun 27, 2019
Messages
2
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
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Try ShellExecute instead, for example:

CreateObject("Shell.Application").ShellExecute "C:\Users\John\Documents\Test.pdf"
 
Upvote 0

Forum statistics

Threads
1,214,634
Messages
6,120,659
Members
448,975
Latest member
sweeberry

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top