I'm kind of lost on the details of your requirement, but in general to launch a file from within VB6 you can use ShellExecute and its related API functions.
I'm kind of lost on the details of your requirement, but in general to launch a file from within VB6 you can use ShellExecute and its related API functions. I'm not sure where the best reference is for this, but I suppose you can start here. Edit: You're close.
Change this: Private Sub smb3_Click() ShellExecute hWnd, "find", "C:\hi\my. File", vbNullString, vbNullString, SW_SHOWNORMAL End Sub to this: Private Sub smb3_Click() ShellExecute hWnd, "open", "C:\hi\my. File", vbNullString, vbNullString, SW_SHOWNORMAL End Sub Note what I changed: The second argument to ShellExecute should be "open" to open the specified file using the program on your machine that's associated with the extension of the file you're trying to open (the function's third argument).
Check the link I included. Which leads to something else you need to check on your machine (and the machines you'll use your program on). The file extension .
File should be associated with whatever program you want to launch with your program. Edit (Sept 9) OK, let's see if we get the simplist implementation of ShellExecute to work. Create a new VB6 project (Standard EXE) and add to Form1 one button named smb1.
Go to the form's Code View and copy and paste this code (and only this code): Option Explicit 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 Sub smb3_Click() Debug. Print ShellExecute(hWnd, "open", "C:\hi\my.
Txt", vbNullString, vbNullString, 1) End Sub Make sure there's a text file called my. Txt in your "c:\hi" folder. Run the program and click the button.It should open the text file with the default text file editor program you have configured on your machine (wuch as Notepad).
If it doesn't please tell me what error you get and on which line the error occurs. Also, check the Immediate Window. The Immediate Window I believe will be visible as soon as you start your program and will remain visible as long as your program is running.
If your code reaches and runs past the line with ShellExecute, the Immediate Window will display the code the call to that function returned. This will tell us a lot about your problem. If the code works, we can think about changing the program to work on the file you need it to work on - on "C:\hi\my.
File". But first what happens when you double click the file in Windows Explorer? If the file opens up then we know there's a program that your system associated with files having the .
File extension. If the file does not open you need to associate a program with the . File extension.
Check Windows help for more. Once we're set, in your test program change the code in your smb3 Click Event to: Debug. Print ShellExecute(hWnd, "open", "C:\hi\my.
File", vbNullString, vbNullString, 1) Run this and click the program. The file should open. If not, tell me what error you get and where, and tell me what (if anything) is in the Immediate Window.
If the program does open then you have in the button's click event and your declaration of ShellExecute the code you need to open files programmatically. But there's still a change you must make and changes you should make. The change you must make is in the button's click event.
We'll remove the debugging code so you end up with this: ShellExecute hWnd, "open", "C:\hi\my. File", vbNullString, vbNullString, 1 The changes you should make involve some basic error handling around the call to ShellExecute. ShellExecute returns a code when it runs.
This code could indicate an error. Study the sample program you can download on the page I linked above.In it, the programmer writes the result of his call to a variable called result. If result is equal to or less than 32 this indicates an error.
In the sample program the error is displayed in an error message but think about what you might want to do.
Basically its just supposed to open a file when I press a button and thats not helping me, I get a "Sub or Function not defined" error – David Aug 31 '09 at 23:49 It's hard for me to say what the problem is without seeing some code. I suggest scrolling to the bottom of the page I linked and downloading the sample, which does work. Study it (especially the cmdExecute_Click event) and move over the parts you need to your project.
You won't have to move much, so don't be discouraged by the number of lines in the sample. Don't forget the declarations on the top of the sample form, you'll need at least one for ShellExecute. – Jay Riggs Sep 1 '09 at 0:06 this is my code: Private Sub smb3_Click() ShellExecute hWnd, "find", "C:\hi\my.
File", _ vbNullString, vbNullString, SW_SHOWNORMAL End Sub – David Sep 1 '09 at 0:19 See my edit. – Jay Riggs Sep 1 '09 at 3:53 ok I did that but I still get the error and it highlights the "Private Sub smb3_Click()" part – David Sep 1 '09 at 1:07.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.