|
-
May 8th, 2005, 02:01 PM
#1
Thread Starter
Lively Member
[SORTED]Shell Exe help..
Out of pure boredom I just tried this:
VB Code:
Private Sub Command1_Click()
Dim PFEnvironVar As String
Dim FilePath As String
PFEnvironVar = Environ$("PROGRAMFILES")
FilePath = PFEnvironVar & "\MSN Messenger\mailtmpl.txt"
MsgBox FilePath
Shell FilePath, vbNormalFocus
End Sub
FilePath produces the right directory and everything, but the shell doesn't seem to work... Would like to know what i'm doing wrong 
Thanks
Edit: I'm getting "File not found" but I know it exists...
Last edited by BefunMunkToloGen; May 8th, 2005 at 02:10 PM.
-
May 8th, 2005, 02:05 PM
#2
Re: Shell Exe help..
Use the SHGetSpecialFolderLocation API instead.
Also, Shell doesnt like spaces in the path.
Use ShellExecute API for best results.
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 
-
May 8th, 2005, 02:07 PM
#3
Thread Starter
Lively Member
Re: Shell Exe help..
So it doesn't work purely because of the spaces...? I don't really want to use API's either.. I've used SHGetFolderLocation before. I'm trying to get this to work 
Cheers
-
May 8th, 2005, 02:08 PM
#4
Re: Shell Exe help..
 Originally Posted by BefunMunkToloGen
Out of pure boredom I just tried this:
VB Code:
Private Sub Command1_Click()
Dim PFEnvironVar As String
Dim FilePath As String
PFEnvironVar = Environ$("PROGRAMFILES")
FilePath = PFEnvironVar & "\MSN Messenger\mailtmpl.txt"
MsgBox FilePath
Shell FilePath, vbNormalFocus
End Sub
FilePath produces the right directory and everything, but the shell doesn't seem to work... Would like to know what i'm doing wrong
Thanks
I do not think Shell likes spaces in its function's perameters, try this:
VB Code:
Private Const SW_SHOWNORMAL = 1
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
Dim strPFEnvironVar As String
Dim strFilePath As String
strPFEnvironVar = Environ$("PROGRAMFILES")
strFilePath = strPFEnvironVar & "\MSN Messenger\mailtmpl.txt"
ShellExecute Me.hwnd, vbNullString, strFilePath, vbNullString, "C:\", SW_SHOWNORMAL
Cheers,
RyanJ
-
May 8th, 2005, 02:11 PM
#5
Re: [SORTED]Shell Exe help..
Just about the only way to get it to work without using APIs is to double up on the double quotes around the spaces.
Also, you shouldnt rely on the Environ variable since it can be changed or deleted.
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 
-
May 8th, 2005, 02:11 PM
#6
Thread Starter
Lively Member
Re: [SORTED]Shell Exe help..
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
|