?
Solved

Receive File with Drop

Posted on 1998-10-20
5
Medium Priority
?
154 Views
Last Modified: 2011-10-03
I want to have a form on to which the user can drag a file.  I want the drop to be an event, so that I can process the file as necessary.  How do I report the path to the file to a variable, and which event should I use to execute my code?
0
Comment
Question by:IsleOfView
[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
5 Comments
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1440793
Set OleDropMode to Automatic.
Now you will receive an event.
0
 
LVL 5

Expert Comment

by:AnswerTheMan
ID: 1440794
Mirkwood : i've a feeling u got him all wrong.
IsleOfView: what exactly do u mean : "Dragging a file" ?
0
 

Author Comment

by:IsleOfView
ID: 1440795
I want to be able to drag a file from Windows Explorer, Desktop or whatever, get the filename into a variable, and execute code from there.  I know that the OleDrop mode will give me an event, but how do I get the filename? (i.e. "c:\testing\mytext.txt")
0
 
LVL 15

Accepted Solution

by:
ameba earned 200 total points
ID: 1440796
Set OleDropMode property of your Form to Manual.

' use its OLEDragDrop event
Private Sub Form1_OLEDragDrop(Data As DataObject, Effect ...)
    Call OLEDragDrop(Data)
End Sub

Public Sub OLEDragDrop(Data As DataObject)
    Dim i%, numfile%, filetxt$, filnam As String
    If Data.GetFormat(vbCFFiles) Then
        On Error GoTo NEXTFILE
        For i = 1 To Data.Files.Count
            filnam = CStr(Data.Files.Item(i))
            numfile% = FreeFile
            Open filnam For Input As #numfile%
            'read file and do something, e.g. show first line
            Line Input #numfile%, filetxt$
            MsgBox filnam & vbCrLf & filetxt$
            Close numfile%
NEXTFILE:
        Next
    End If
End Sub
0
 

Author Comment

by:IsleOfView
ID: 1440797
Thank you...that worked perfectly.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
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…
Suggested Courses

718 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