|
-
Jun 19th, 2006, 11:40 AM
#1
Thread Starter
Addicted Member
RESOLVED[Problem with Shell]
I can't find out why, whenever I try to run Shell instruction, I get run time error 5 saying "Invalid procedure call or argument"
Last edited by Fonty; Jun 19th, 2006 at 04:01 PM.
-
Jun 19th, 2006, 11:45 AM
#2
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 
-
Jun 19th, 2006, 01:32 PM
#3
Thread Starter
Addicted Member
Re: Problem with Shell
VB Code:
Sub cmdButton_Click()
Shell ("C:\directory\file.xls")
End Sub
-
Jun 19th, 2006, 01:35 PM
#4
Re: Problem with Shell
Remove the parenthesis and it should be ok but if you right click on Shell does it bring up the object browser to it?
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 
-
Jun 19th, 2006, 01:41 PM
#5
Thread Starter
Addicted Member
Re: Problem with Shell
In fact, I've tried either with or without parenthesis, and it gives the same error. When I run the user form with the button, nothing appears with right click.
-
Jun 19th, 2006, 01:46 PM
#6
Re: Problem with Shell
No, i mean to right click on the work Shell to see if its linked in the Object Browser. Not 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 
-
Jun 19th, 2006, 01:58 PM
#7
Thread Starter
Addicted Member
Re: Problem with Shell
In the object browser I can find it in the Interaction class.
-
Jun 19th, 2006, 02:01 PM
#8
Re: Problem with Shell
Ok, thats good so far. Its in the "VBA.Interaction". Now if you change the path to some other path that has no permissions issues or such just for testing. Try Shell C:\Book1.xls On a new blank workbook. We need to identify where the issue lies. Either in the file or the location.
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 
-
Jun 19th, 2006, 02:03 PM
#9
Thread Starter
Addicted Member
Re: Problem with Shell
Location is working fine, if I write a inexistent file it says it doesn't exist.
-
Jun 19th, 2006, 02:04 PM
#10
Re: Problem with Shell
Did you test it on an actual new blank workbook?
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 
-
Jun 19th, 2006, 02:08 PM
#11
Re: Problem with Shell
are u running this in excel vba???
why not directly open the workbook instead of shell!??
Workbooks.Open
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jun 19th, 2006, 03:21 PM
#12
Thread Starter
Addicted Member
Re: Problem with Shell
Yes, in fact i just wrote that line in a new workbook.
I want to use shell because I'm trying to make a userform that allows you to explore the files contained in a directory and opening them, ot all of them are excel workbooks.
-
Jun 19th, 2006, 03:24 PM
#13
Re: Problem with Shell
the use ShellEx API
it will make it easier
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jun 19th, 2006, 03:32 PM
#14
Thread Starter
Addicted Member
Re: Problem with Shell
how do I run this instruction?
-
Jun 19th, 2006, 03:38 PM
#15
Re: Problem with Shell
VB Code:
Private Declare Function ShellEx Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As Any, _
ByVal lpDirectory As Any, ByVal nShowCmd As Long) As Long
Private Sub Command1_Click()
Dim x
x = ShellEx(application.Hwnd , "open", "path of file.ext" , "", "", 1)
End Sub
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jun 19th, 2006, 03:38 PM
#16
Re: Problem with Shell
oops.. forgot the explanation.. this will open the file with the default app...
so xls will open with excel, txt with notepad (or whatever text editor u have as the default)
etc...
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jun 19th, 2006, 03:59 PM
#17
Thread Starter
Addicted Member
Re: Problem with Shell
It works just perfect. Any clue of why it didn't work with Shell instruction?
Where or how could I learn to do more advanced things such as using libraries etc...?
-
Jun 19th, 2006, 04:10 PM
#18
Re: RESOLVED[Problem with Shell]
I am curious why the Shell didnt work. It should be working.
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 
-
Jun 19th, 2006, 04:14 PM
#19
Re: RESOLVED[Problem with Shell]
It doesn't work with Shell because Shell only opens executables. Try:
and it'll work.
zaza
-
Jun 19th, 2006, 04:17 PM
#20
Re: RESOLVED[Problem with Shell]
Son of .... Thats it I'm taking a break from VBF for a while. Time for lunch anyways.
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 
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
|