Solved

Loading Data into a VB program by clicking on data file

Posted on 2002-03-03
4
131 Views
Last Modified: 2010-05-02
When I click on a Microsoft Word document, it will bring up Microsoft Word and load the document.
I am writing a program in VB6 which can load the data I choose once it is running.  I would like to click on the data in Explorer and have my program execute and load the data I clicked on.  How can I do this?
Thanks, Harold
0
Comment
Question by:hlominac
  • 2
4 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 6838290
0
 

Author Comment

by:hlominac
ID: 6838465
OK, I am able to bring up the executable program.  I already could do this because I had set it up with microsoft programs in explorer.
I need to read the name of the data file into my program.  Once I have its name and path I can load it.  What code do I use in VB6 to do this?
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6838673
Is this what you want?  It starts the program that handles a data file of a specified type and passes the filename of that data file to that program.

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

ErrorLevel= _
ShellExecute(Me.hwnd, _
     "open", "MyDataFIle.ZXZ", "",_
     "", vbNormalFocus)
If ErrorLevel < 32 Then
     MsgBox "There is no association set up for files of type ZXZ",_
               vbExclamation
End If

-- Dan
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 100 total points
ID: 6838756
In your Form_Load event (or in the Sub Main procedure), read the value stored into COMMAND:

strFileName = Command
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

815 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now