Solved

Loading Data into a VB program by clicking on data file

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

757 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

16 Experts available now in Live!

Get 1:1 Help Now