Please bear with me... I am new at this stuff.
Thanks to a posting of ADezii (https://bytes.com/topic/access/answers/947863-how-create-drag-drop-field-files), drag and drop files from Explorer in to a listview can be done in Access. I thankfully used his code and tried to enhance it for me. see the attachement. However I encountered some problems, one of which is the following.
In Switzerland we use the German, French and Italian language, which use the special characters like üöäç. If had a filename with "ü" in it and it came back in the ListView1 (and strKey or varFileName) as
"u¨". Correcting it with the function varFileName = Replace(varFile Name, "u¨", "ü") displayed it correctly in the Listview, but using this text could not open such file with my added, where any other file could be opened.
from a Module of Richard Rost(ShellexecM )
I really appreciate the help here!
Cheers Richard
Thanks to a posting of ADezii (https://bytes.com/topic/access/answers/947863-how-create-drag-drop-field-files), drag and drop files from Explorer in to a listview can be done in Access. I thankfully used his code and tried to enhance it for me. see the attachement. However I encountered some problems, one of which is the following.
In Switzerland we use the German, French and Italian language, which use the special characters like üöäç. If had a filename with "ü" in it and it came back in the ListView1 (and strKey or varFileName) as
"u¨". Correcting it with the function varFileName = Replace(varFile Name, "u¨", "ü") displayed it correctly in the Listview, but using this text could not open such file with my added, where any other file could be opened.
Code:
Private Sub TreeView1_DblClick() ShellExec gbl_seletedKey ' End Sub
Code:
Option Compare Database Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _ (ByVal hwnd As Long, ByVal lpszOp As String, _ ByVal lpszFile As String, ByVal lpszParams As String, _ ByVal LpszDir As String, ByVal FsShowCmd As Long) _ As Long Private Const ERR_SUCCESS = 32 Private Const ERR_NO_ASSOC = 31 Private Const ERR_OUT_OF_MEM = 0 Private Const ERR_FILE_NOT_FOUND = 2 Private Const ERR_PATH_NOT_FOUND = 3 Private Const ERR_BAD_FORMAT = 11 Private Const SW_HIDE = 0 Private Const SW_SHOWNORMAL = 1 Private Const SW_NORMAL = 1 Private Const SW_SHOWMINIMIZED = 2 Private Const SW_SHOWMAXIMIZED = 3 Private Const SW_MAXIMIZE = 3 Private Const SW_SHOWNOACTIVATE = 4 Private Const SW_SHOW = 5 Private Const SW_MINIMIZE = 6 Private Const SW_SHOWMINNOACTIVE = 7 Private Const SW_SHOWNA = 8 Private Const SW_RESTORE = 9 Private Const SW_SHOWDEFAULT = 10 Private Const SW_MAX = 10 Public Sub ShellExec(FileToOpen As String, Optional Params As String = "", Optional DefaultDir As String = "", Optional ShowHow As Long = 1) Dim L As Long L = ShellExecute(0, "OPEN", FileToOpen, Params, DefaultDir, SW_SHOWNORMAL) If L < ERR_SUCCESS Then Select Case L Case ERR_NO_ASSOC: MsgBox "No program is associated with this file type" Case ERR_OUT_OF_MEM: MsgBox "Out of memory" Case ERR_FILE_NOT_FOUND: MsgBox "File not found" Case ERR_PATH_NOT_FOUND: MsgBox "Path not found" Case Else: MsgBox "Unknown error" End Select Exit Sub End If End Sub ' Error handling on: http://support.microsoft.com/kb/170918 ' OPEN ' EXPLORE ' FIND ' EDIT ' PRINT ' PROPERTIES ' RUNAS for elevated status
Cheers Richard
Comment