Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
InputBox - Browse
Dear Friends,
how can I add a browse button on an inputbox? I added a default value (path) but I want to give the user the option to select a file to read through a browse button. Thanks, G. --- Message posted from http://www.ExcelForum.com/ |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
InputBox - Browse
This code below will run a folder browse dialog and return the selected
folder This is a demo of how to use it MsgBox GetFolder Watch wrap-around. '============================== 'Code starts here Private Declare Function SHGetPathFromIDList Lib "shell32.dll" _ Alias "SHGetPathFromIDListA" _ (ByVal pidl As Long, _ ByVal pszPath As String) As Long Private Declare Function SHBrowseForFolder Lib "shell32.dll" _ Alias "SHBrowseForFolderA" _ (lpBrowseInfo As BROWSEINFO) As Long Private Type BROWSEINFO hOwner As Long pidlRoot As Long pszDisplayName As String lpszTitle As String ulFlags As Long lpfn As Long lParam As Long iImage As Long End Type '------------------------------------------------------------- Function GetFolder(Optional ByVal Name As String = "Select a folder.") As String '------------------------------------------------------------- Dim bInfo As BROWSEINFO Dim path As String Dim oDialog As Long bInfo.pidlRoot = 0& 'Root folder = Desktop bInfo.lpszTitle = Name bInfo.ulFlags = &H1 'Type of directory to return oDialog = SHBrowseForFolder(bInfo) 'display the dialog 'Parse the result path = Space$(512) GetFolder = "" If SHGetPathFromIDList(ByVal oDialog, ByVal path) Then GetFolder = Left(path, InStr(path, Chr$(0)) - 1) End If End Function -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "banavas " wrote in message ... Dear Friends, how can I add a browse button on an inputbox? I added a default value (path) but I want to give the user the option to select a file to read through a browse button. Thanks, G. --- Message posted from http://www.ExcelForum.com/ |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
InputBox - Browse
Works OK for the most part, but you can select cells while the dialog is
open. You can get around it by doing something like: Private Declare Function FindWindow Lib "user32.dll" _ Alias "FindWindowA" ( _ ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long .... bInfo.hOwner = FindWindow(vbNullString, Application.Caption) -- Rob van Gelder - http://www.vangelder.co.nz/excel "Bob Phillips" wrote in message ... This code below will run a folder browse dialog and return the selected folder This is a demo of how to use it MsgBox GetFolder Watch wrap-around. '============================== 'Code starts here Private Declare Function SHGetPathFromIDList Lib "shell32.dll" _ Alias "SHGetPathFromIDListA" _ (ByVal pidl As Long, _ ByVal pszPath As String) As Long Private Declare Function SHBrowseForFolder Lib "shell32.dll" _ Alias "SHBrowseForFolderA" _ (lpBrowseInfo As BROWSEINFO) As Long Private Type BROWSEINFO hOwner As Long pidlRoot As Long pszDisplayName As String lpszTitle As String ulFlags As Long lpfn As Long lParam As Long iImage As Long End Type '------------------------------------------------------------- Function GetFolder(Optional ByVal Name As String = "Select a folder.") As String '------------------------------------------------------------- Dim bInfo As BROWSEINFO Dim path As String Dim oDialog As Long bInfo.pidlRoot = 0& 'Root folder = Desktop bInfo.lpszTitle = Name bInfo.ulFlags = &H1 'Type of directory to return oDialog = SHBrowseForFolder(bInfo) 'display the dialog 'Parse the result path = Space$(512) GetFolder = "" If SHGetPathFromIDList(ByVal oDialog, ByVal path) Then GetFolder = Left(path, InStr(path, Chr$(0)) - 1) End If End Function -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "banavas " wrote in message ... Dear Friends, how can I add a browse button on an inputbox? I added a default value (path) but I want to give the user the option to select a file to read through a browse button. Thanks, G. --- Message posted from http://www.ExcelForum.com/ |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
InputBox - Browse
Hi Banavas,
how can I add a browse button on an inputbox? I added a default value (path) but I want to give the user the option to select a file to read through a browse button. Create your own userform for the input box and instead of a normal text box, use a ComboBox with the dropdown style set to ellipsis. Then in the _Dropdown event procedure, add the code to show the Browse dialog. Regards Stephen Bullen Microsoft MVP - Excel www.BMSLtd.ie |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
InputBox - Browse
If you want to select a file, it might be just as straight forward to put a
command button on a userform and have the command button issue a Chdrive "C" Chdir "C:\My Default Folder" fName = Application.GetOpenFileName see help on GetOpenFileName for argument options. There isn't much you can do with an inputbox itself using built in capabilities. -- Regards, Tom Ogilvy "banavas " wrote in message ... Dear Friends, how can I add a browse button on an inputbox? I added a default value (path) but I want to give the user the option to select a file to read through a browse button. Thanks, G. --- Message posted from http://www.ExcelForum.com/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Trying to browse Add-ins???? | Excel Discussion (Misc queries) | |||
Browse Desktop | Excel Discussion (Misc queries) | |||
Browse File for Mac | Excel Discussion (Misc queries) | |||
can't browse file | Excel Discussion (Misc queries) | |||
Browse Dialog Box in VBA? | Excel Programming |