Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default GetOpenFileName

Hello

I'm trying to understand Stephen Bullen's and Rob Bovey's
GetOpenFileName routine which appears
to do something the standard GetOpenFileName doesn't. I'm noticing
that the filename under the cursor
is immediately reflected in the Filename combo box whenever the valid
selection is changed. Is this an
indication that the change of filename could trigger additional code
while the dialog is still active?
For example to populate a small worksheet range with text from a
".txt" file to illuminate it's content.

Thanks in advance
Oswald

BTW This group is excellent!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default GetOpenFileName


You may want to understand dialog boxes better. All dialog boxes are
par tof the comdlg32.dll (common dialog) in the windows\system32 folder.
Excel dates back to Office 97 and the standard VBA Getopenfilenames
only impliments the feature available at the time Office 97 was released
so Excel stys upward compatible from version to version.

GetOpenfile name in VBA is only a wrapper which calls the comdlg32.dll.
Yo can get the complete definition of the Current GetOPenfilename from
the DLL library definition at

'GetOpenFileName Function ()'
(http://msdn.microsoft.com/en-us/libr...27(VS.85).aspx)

From VBA you can call any DLL by simply defining the library call.

Below is some code I wrote which uses the Folder Picker using the same
DLL. I was working with somebody who was using Excel 2000 which didn't
have this dialog built into VBA. Actually the File Picker Dialog
(GETOPENFILENAME) and the folder Picker Dialog are vfery similar and
just called the same low level routines with different options.




Private Const BIF_RETURNONLYFSDIRS As Long = &H1
Private Const BIF_DONTGOBELOWDOMAIN As Long = &H2
Private Const BIF_RETURNFSANCESTORS As Long = &H8
Private Const BIF_BROWSEFORCOMPUTER As Long = &H1000
Private Const BIF_BROWSEFORPRINTER As Long = &H2000
Private Const BIF_BROWSEINCLUDEFILES As Long = &H4000
Private Const MAX_PATH As Long = 260

Type BrowseInfo
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszINSTRUCTIONS As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type

Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Boolean
hNameMappings As Long
lpszProgressTitle As String
End Type

Declare Function SHGetPathFromIDListA Lib "shell32.dll" ( _
ByVal pidl As Long, _
ByVal pszBuffer As String) As Long

Declare Function SHBrowseForFolderA Lib "shell32.dll" ( _
lpBrowseInfo As BrowseInfo) As Long


Function BrowseFolder(Optional Caption As String = "") As String

Dim BrowseInfo As BrowseInfo
Dim FolderName As String
Dim ID As Long
Dim Res As Long

With BrowseInfo
hOwner = 0
pidlRoot = 0
pszDisplayName = String$(MAX_PATH, vbNullChar)
lpszINSTRUCTIONS = Caption
ulFlags = BIF_RETURNONLYFSDIRS
lpfn = 0
End With

FolderName = String$(MAX_PATH, vbNullChar)
ID = SHBrowseForFolderA(BrowseInfo)
If ID Then
Res = SHGetPathFromIDListA(ID, FolderName)
If Res Then
BrowseFolder = Left$(FolderName, InStr(FolderName, vbNullChar) -
1)
End If
End If

End Function


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=187210

http://www.thecodecage.com/forumz/chat.php

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fun with GetOpenFilename WhytheQ Excel Programming 4 February 16th 08 03:10 PM
Using GetOpenFilename Chaplain Doug Excel Programming 3 February 6th 07 09:01 PM
GetOpenFileName with F*.txt DRK Excel Programming 6 June 7th 05 12:45 PM
GetOpenFileName help Leith Ross[_12_] Excel Programming 0 April 8th 05 10:14 PM
getopenfilename inquirer Excel Programming 1 December 3rd 03 11:37 AM


All times are GMT +1. The time now is 09:49 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"