Solved

Loading Data into a VB program by clicking on data file

Posted on 2002-03-03
4
133 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

685 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