Solved

Loading Data into a VB program by clicking on data file

Posted on 2002-03-03
4
134 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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.
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…
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…

739 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