Solved

Loading Data into a VB program by clicking on data file

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

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 69

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

911 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

21 Experts available now in Live!

Get 1:1 Help Now