|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
I need to a code to open a .doc file (with its default program e.g Microsoft Word).. when you click on a command button...
Can anyone help? Thanks in advance. ![]() |
|
#2
|
|||
|
|||
|
You will need to use window's API to do this function as VisualBasic doesn't have internal workings to do that.
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 Then you call it like this: Code:
ShellExecute Me.hWnd, vbNullString, PathAndFileName, "C:\", SW_SHOWNORMAL I hope that this helps. Also, you may want to go to www.developerfusion.com, where they have a lot of different articles for Visual Basic including API functions such as this one. Last edited by spak111 : July 23rd, 2004 at 02:36 PM. Reason: error |
|
#3
|
|||
|
|||
|
Thank you spak111, i'll try that.
|
|
#4
|
|||
|
|||
|
error in code
[QUOTE=spak111]You will need to use window's API to do this function as VisualBasic doesn't have internal workings to do that.
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 This brings up an error: Compile Error: Only Comments may appear after End Sub, End Function, or End Property. What should I do? |
|
#5
|
|||
|
|||
|
Okay, you need to make sure that the code that you pasted above is in the general declarations portion of your project. If it is not, it will cause an error. Also, if that still doesn't work for you, don't declare SW_SHOWNORMAL as a constant, just remember to change where SW_SHOWNORMAL is in the call, to a '1'. I hope this helps fix your problem.
|
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Visual Basic 6: Executing File from Command Button |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|