|
-
Feb 21st, 2010, 07:15 PM
#1
Thread Starter
Lively Member
[RESOLVED] VBA Code SHELL Not Working
Hi, i am using the following code to close down an .exe program.
Code:
Dim sKillMagnify As String
sKillMagnify = "TASKKILL /F /IM Magnify.exe"
Shell sKillMagnify, vbHide
I used the code in powerpoint in vista and it worked perfectly, but when i am using the code in XP i get an error on
Code:
Shell sKillMagnify, vbHide
saying Run-time error '53': File not found.
Thanks.
-
Feb 21st, 2010, 08:03 PM
#2
Re: VBA Code SHELL Not Working
Taskkill.exe and magnify.exe both are located in the system32 directory under XP. Perhaps verifying the directory path is correct that you are passing at runtime.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 22nd, 2010, 02:15 PM
#3
Thread Starter
Lively Member
Re: VBA Code SHELL Not Working
Hi, could you please explain further, i didnt quite understand your post.
Thank you.
-
Feb 22nd, 2010, 02:26 PM
#4
Re: VBA Code SHELL Not Working
Place a breakpoint on on "Shell sKillMagnify, vbHide" and see what the value of sKillMagnify is. It may not be the value you expect.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 22nd, 2010, 02:45 PM
#5
Thread Starter
Lively Member
Re: VBA Code SHELL Not Working
Hi, what do you mean by place a breakpoint.
The exact code works perfectly on powerpoint in windows vista, but it is not working on xp so i know there is nothing wrong with the code.
thanks
-
Feb 22nd, 2010, 03:34 PM
#6
Re: VBA Code SHELL Not Working
Well as I was saying you can not assume the code will workon different operating systems.
In the IDE, place your cursor on the line of code to stop execution on for debugging. Then press F9. A red line will appear. Run your code and when it stops at that line. Check the value of the variable.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 22nd, 2010, 03:35 PM
#7
Re: VBA Code SHELL Not Working
so i know there is nothing wrong with the code.
as there is nothing wrong with the code it must be working fine
you may need to provide full paths to boh the files like
c:\windows\sysem32\taskill.exe
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Feb 23rd, 2010, 03:26 AM
#8
Member
Re: VBA Code SHELL Not Working
Try This Out:
Code:
Dim Error
strComputer = "<Replace With Your Local Machine Name Or Remote server Name>"
Set objWMIService = GetObject _
("winmgmts:\\" & strComputer & "\root\cimv2:Win32_Process")
Error = objWMIService.Create("<Replace with Name Of Process You Want To Execute>", Null, Null, intProcessID)
If Error = 0 Then
MsgBox "Process was started with a process ID of " _
& intProcessID & "."
Else
MsgBox "Process could not be executed due to error " & _
Error & "."
End If
Ensure that the process which you want to trigger it's exe file must exist on System32 (c:\windows\system32) Folder
-
Feb 24th, 2010, 01:13 PM
#9
Thread Starter
Lively Member
Re: VBA Code SHELL Not Working
Hi, the original code is working on another XP machine, so i know the code is working fine on both XP and Vista. I'll just use the other xp machine.
Thanks for all the help
-
Feb 24th, 2010, 01:29 PM
#10
Re: VBA Code SHELL Not Working
If it works on one XP and not another XP then are both accouts the same?
If this issue is settled then please dont forget to use the thread tools and select Mark Thread as Resolved so others know its done
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 25th, 2010, 06:25 PM
#11
Thread Starter
Lively Member
Re: VBA Code SHELL Not Working
It is only working on one XP, I don't understand why it dosn't work on the other XP computer, but it's not a problem.
Thanks For All The Help.
-
May 21st, 2013, 08:51 PM
#12
New Member
Re: [RESOLVED] VBA Code SHELL Not Working
The reason it didn't work on Khadafi's other XP PC is b/c that PC didn't have taskkill.exe in system32 directory.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|