Terry-
Thank you for your prompt response. I truly appreciate your help.
Just a couple more questions...I have the code working, and it stores
the displayed path in a table after also extracting the filename (to be
used as a "link" to be used later in the apiShellExecute function to
open the linked file). I see where you mention that multiple files can
be dragged to the listbox on the form, and this works just fine as well,
all paths being seperated by a ";". I would like to add this
functionality to the form (to add more than just one file), but when
executed the code only stores the first file's path in the table, and
neither the filecopy or the filename parsing functions work because I am
not sure where to place these within the function. Could you provide
any insight? The code is posted below. I only started using Access
about 4 weeks ago, so I apologize for any glaring errors! ;) Thanks in
advance for your help! :)
Michael
'code from
http://www.mvps.org/access/api/api0032.htm,_
'"API: Drag and Drop from Explorer"
'************* Code Start *************
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Sub sDragDrop(ByVal hwnd As Long, _
ByVal Msg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long)
Dim lngRet As Long, strTmp As String, intLen As Integer
Dim lngCount As Long, i As Long, strOut As String
Dim filename As String
Dim infilename As Long
Dim dest As String
Const cMAX_SIZE = 255
On Error Resume Next
If Msg = WM_DROPFILES Then
strTmp = String$(255, 0)
lngCount = apiDragQueryFile(wParam, &HFFFFFFFF, _
strTmp, Len(strTmp))
For i = 0 To lngCount - 1
strTmp = String$(cMAX_SIZE, 0)
intLen = apiDragQueryFile(wParam, i, strTmp, _
cMAX_SIZE)
strOut = strOut & Left$(strTmp, intLen) & ";"
Next i
strOut = Left$(strOut, Len(strOut) - 1)
Call sapiDragFinish(wParam)
Debug.Print strOut
With Forms!Drag_Files_Here!lstDrop 'modified _
'form name from frmDragDrop
.RowSourceType = "Value List"
.RowSource = strOut
Forms!Drag_Files_Here.Caption = _
"Attached File(s): " & .ListCount
infilename = Len(strOut)
filename = Right$(strOut, infilename - _
InStrRev(strOut, "\"))
Forms!Drag_Files_Here!Filenames = filename
dest = "c:\" & filename
Forms!Drag_Files_Here!link = dest
FileCopy strOut, dest
Forms!Drag_Files_Here!Issue_ID = _
Forms!Add_New_Issue!Issue_ID
End With
Else
lngRet = apiCallWindowProc( _
ByVal lpPrevWndProc, _
ByVal hwnd, _
ByVal Msg, _
ByVal wParam, _
ByVal lParam)
End If
End Sub
'other functions used:
'
'
'
Option Compare Database
Option Explicit
Function ParsePath(strPath As String, lngPart As Integer) As String
' This procedure takes a file path and returns
' the path (everything but the file name), the
' file name, the drive letter, or the file extension,
' depending on which constant was passed in.
Dim lngPos As Long
Dim strPart As String
Dim blnIncludesFile As Boolean
Dim intLenofExt As Integer
' Check that this is a file path.
' Find the last path separator.
lngPos = InStrRev(strPath, "\")
'If not fullstop add one
If InStr(strPath, ".") = 0 Then strPath = strPath & "."
' Determine whether portion of string after last _
'backslash
' contains a period.
blnIncludesFile = InStrRev(strPath, ".") > lngPos
If lngPos > 0 Then
Select Case lngPart
' Return file name.
Case 1
If blnIncludesFile Then
intLenofExt = Len(Mid(strPath, _
InStrRev(strPath, ".") + 1))
strPart = Right$(strPath, _
Len(strPath) - lngPos)
' do not include the _
'file ext in the filename
strPart = Left(strPart, _
Len(strPart) - (intLenofExt + 1))
Else
strPart = Right$(strPath, _
Len(strPath) - lngPos)
End If
' Return path.
Case 2
If blnIncludesFile Then
strPart = Left$(strPath, lngPos)
Else
strPart = strPath
End If
' Return drive.
Case 3
strPart = Left$(strPath, 3)
' Return file extension.
Case 4
If blnIncludesFile Then
' Take three characters and period.
strPart = Mid(strPath, _
InStrRev(strPath, "."), 4)
Else
strPart = ""
End If
Case Else
strPart = ""
End Select
End If
ParsePath = strPart
ParsePath_End:
Exit Function
End Function
Public Function InStrRev( _
StringCheck As String, _
StringMatch As String, _
Optional Start As Long = -1, _
Optional Compare As Integer = 2) _
As Long
'-------------------------------------------------------'----
' Inputs: String to check,
' match string,
' optional starting position (default = -1),
' optional string compare _
'value (default vbDatabaseCompare)
' Outputs: Position of match string, starting from _
'the end
' Original code by: John L. Viescas 15-Nov-2001
' Revised by: Dirk Goldgar 21-Jan-2002
' Last Revision: Dirk Goldgar 21-Jan-2002
' ** Duplicates the functionality of the VB 6 _
'INSTRREV function.
'-------------------------------------------------------'----
Dim lngS As Long, lngI As Long
Dim lngLenC As Long, lngLenM As Long
' Do some initial checks
If (Compare < 0) Or (Compare > 2) Then
Err.Raise 5
Exit Function
End If
If Len(StringCheck) = 0 Then
InStrRev = 0
Exit Function
End If
If Len(StringMatch) = 0 Then
InStrRev = Start
Exit Function
End If
If Start > Len(StringCheck) Then
InStrRev = 0
Exit Function
End If
If Len(StringMatch) > Len(StringCheck) Then
InStrRev = 0
Exit Function
End If
' OK, have some work to do!
lngS = Start
lngLenC = Len(StringCheck)
lngLenM = Len(StringMatch)
If lngS = -1 Then lngS = lngLenC
lngS = (lngS - lngLenM) + 1
' Set default not found
InStrRev = 0
' Now loop to see if we can find it
For lngI = lngS To 1 Step -1
If StrComp(Mid$(StringCheck, lngI, lngLenM), _
StringMatch, Compare) = 0 _
Then
InStrRev = lngI
Exit For
End If
Next lngI
End Function
*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!