|
-
May 3rd, 2005, 07:07 PM
#1
Thread Starter
Hyperactive Member
shell files
if you shell a .txt file will it open it in notepad?
i ask because it would be easy to run files like that from vb if you did not need to find what had to open them
It's not just Good, It's Good enough!
Spelling Eludes Me
-
May 3rd, 2005, 07:14 PM
#2
-
May 3rd, 2005, 07:16 PM
#3
Thread Starter
Hyperactive Member
Re: shell files
shellexecute api?
elaborate
It's not just Good, It's Good enough!
Spelling Eludes Me
-
May 3rd, 2005, 07:17 PM
#4
Re: shell files
Examples for both options :
VB Code:
Shell "notepad C:\file.txt", vbNormalFocus
Or :
VB Code:
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
Const SW_SHOWNORMAL = 1
Private Sub Form_Load()
ShellExecute Me.hwnd, "open", "C:\file.txt", vbNullString, "C:\", SW_SHOWNORMAL
End Sub
Has someone helped you? Then you can Rate their helpful post. 
-
May 3rd, 2005, 07:18 PM
#5
Re: shell files
The ShellExecute API function is declared in this way:
VB Code:
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
You could use a Sub like the following to open any file:
VB Code:
Public Sub OpenFile(ByVal sFileName As String)
ShellExecute 0, "Open", sFileName, vbNullString, vbNullString, vbNormalFocus
End Sub
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
|