Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
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  
Old July 22nd, 2004, 04:10 AM
agentcid agentcid is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 11 agentcid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Arrow Visual Basic 6: Executing File from Command Button

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.

Reply With Quote
  #2  
Old July 23rd, 2004, 02:36 PM
spak111 spak111 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 349 spak111 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 25 sec
Reputation Power: 5
Send a message via AIM to 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

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

Reply With Quote
  #3  
Old July 24th, 2004, 09:43 PM
agentcid agentcid is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 11 agentcid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thank you spak111, i'll try that.

Reply With Quote
  #4  
Old July 25th, 2004, 04:08 PM
agentcid agentcid is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 11 agentcid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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?

Reply With Quote
  #5  
Old July 26th, 2004, 07:14 AM
spak111 spak111 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 349 spak111 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 25 sec
Reputation Power: 5
Send a message via AIM to spak111
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.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Visual Basic 6: Executing File from Command Button


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway