Solved

How to open a vbp file from visual basic application

Posted on 2002-06-19
5
2,788 Views
Last Modified: 2013-11-25
This must be simple, but i dont seem to get it right?

I have an application which has to open the source code of any application(ie will open a vbp file).

I have a TextBox (say text1) on the form which shows the path of the vbp project.

for eg:
Text1="\\rootpc\D\project\sourcecode\myproject.vbp"

Now at the click of a CommandButton, I write the following code:

Private Sub Command1_Click()
'it gives me an error at this call procedure, saying "Invalid procedure call or argument"

Call Shell(Text1, vbMaximizedFocus)

End Sub

But if i open an exe it works fine. I know I am missing something, anybody who can tell me what?

Thanks
-Priya

0
Comment
Question by:priya_pbk
  • 3
  • 2
5 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 50 total points
ID: 7092124
try this:

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_SHOW = 1

...
  Dim hBrowse As Long
  hBrowse = ShellExecute(0&, "open", text1.text, "", "", SW_SHOW)
...

CHeers
0
 
LVL 2

Author Comment

by:priya_pbk
ID: 7092178
thanks, works fine!

BTW, what's the difference b/w Shell and ShellExecute apart from the fact that the later is faster?

-priya
0
 
LVL 2

Author Comment

by:priya_pbk
ID: 7092191
hey i dont' understand, I have accepted your answer(angelIII) twice by clicking the Accept comment as answer button, but it doesn't seem to work.

Any moderators who can help, I tried Reloading the Question, no luck!!

-priya
0
 
LVL 2

Author Comment

by:priya_pbk
ID: 7092206
oops!!forgot to click the grade -priya
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 7092207
Accept worked...

Shell is a wrapper function of VB for the API shell, and by thus is faster. Of course, the API has more parameters for flexibility, but is not as simple to use as VB functions...

CHeers
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question