I have several programs that after running, they open another piece of software, I decided to modify these programs to open a calculator program before performing its duties. The first one I modified worked as expected, the next one works fine when run from the IDE, but when compiled and I click on the .exe file, the .exe file is deleted! Just tried it with a third program and it did the same thing, works fine in IDE, deletes itself when run from the .exe file. The added code is in red.
The only other thing that has changed is I added the "MouseWheel Fix", which was added before modifying the first program.
Code:
Option Explicit
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_SHOWMAXIMIZED = 3
Private Const SW_SHOWNORMAL = 1
.
.
.
sFileSpec = "C:\Program Files (x86)\J. A. Associates\RPN Engineering Calculator\rpn.exe"
R = True
GoSub DoIt
R = False
sFileSpec = "D:\Documents\DesignCAD\Drawings\Puzzles\star13puzzle.dcd"
.
.
.
DoIt:
rtn = ShellExecute(0, "Open", sFileSpec, vbNullString, vbNullString, SW_SHOWNORMAL)
If R = True Then Return