|
-
Jun 22nd, 2000, 12:14 AM
#1
I need to write an app that prompts the user with an open dialog box. after the user Selects the file, I need to open it. I know how to use the common dialog ShowOpen method, How do I open the file in its respective app. I have no way of knowing the file types in advance. Please help.
thanks,
Brian
-
Jun 22nd, 2000, 12:30 AM
#2
Fanatic Member
Hello BG!
Here is my chance to help you.
With the filename from the commondialog use it with the API ShellExecute.
Code:
Call ShellExecute(GetActiveWindow(), "Open", "Filename.doc", vbNullString, CurDir(), SW_SHOWNORMAL)
Chemically Formulated As:
Dr. Nitro
-
Jun 22nd, 2000, 12:33 AM
#3
Fanatic Member
Here is a more complete version!
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
Private Const SW_SHOWNORMAL = 1
Private Const SW_SHOWMINIMIZED = 2
Private Const SW_SHOWMAXIMIZED = 3
Private Const SW_SHOW = 5
Private Const SW_MINIMIZE = 6
Private Const SW_SHOWMINNOACTIVE = 7
Private Const SW_SHOWNA = 8
Private Const SW_RESTORE = 9
Private Const SW_SHOWDEFAULT = 10
Private Sub Command1_Click()
Call ShellExecute(Me.hwnd, "Open", "Hello.doc", vbNullString, vbNullString, SW_SHOWNORMAL)
End Sub
Chemically Formulated As:
Dr. Nitro
-
Jun 22nd, 2000, 12:36 AM
#4
Fanatic Member
One more thing.
To get the filename after selecting the file, it will be store in "CommonDialog1.Filename". This will include the extention and you can plug it straight into the API.
Chemically Formulated As:
Dr. Nitro
-
Jun 22nd, 2000, 12:43 AM
#5
Right On! thanks alot
Brian
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
|