File Broswer module runs twice

ITguy1981

Registered User.
Local time
Today, 04:55
Joined
Aug 24, 2011
Messages
137
I know enough about code to usually change it to make it work in my databases. I'm currently using this code to open a file browser to pick a file, but after I pick a file and choose open the browser opens again and has me choose a second time. I'm not sure why. I've tried deleting out some parts of the module that I thought may have been the problem without any luck. here is the whole thing.

Private Const VER_PLATFORM_WIN32_NT = 2
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type
Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" _
(ByRef lpVersionInformation As OSVERSIONINFO) As Long
Private Declare Function GetFileNameFromBrowseW Lib "shell32" Alias "#63" _
(ByVal hwndOwner As Long, _
ByVal lpstrFile As Long, _
ByVal nMaxFile As Long, _
ByVal lpstrInitialDir As Long, _
ByVal lpstrDefExt As Long, _
ByVal lpstrFilter As Long, _
ByVal lpstrTitle As Long) As Long
Private Declare Function GetFileNameFromBrowseA Lib "shell32" Alias "#63" _
(ByVal hwndOwner As Long, _
ByVal lpstrFile As String, _
ByVal nMaxFile As Long, _
ByVal lpstrInitialDir As String, _
ByVal lpstrDefExt As String, _
ByVal lpstrFilter As String, _
ByVal lpstrTitle As String) As Long


Public Function BrowseFiles()
Dim sSave As String

sSave = Space(255)
'If we're on WinNT, call the unicode version of the function

GetFileNameFromBrowseW Screen.ActiveForm.hwnd, _
StrPtr(sSave), _
255, _
StrPtr("c:\"), _
StrPtr("txt"), _
StrPtr("Text files (*.txt)" + Chr$(0) + "*.txt" + Chr$(0) + _
"All files (*.*)" + Chr$(0) + "*.*" + Chr$(0)), _
StrPtr("The Title")

BrowseFiles = Trim(Replace(sSave, Chr$(0), " "))
End Function
Public Function IsWinNT() As Boolean
Dim myOS As OSVERSIONINFO

myOS.dwOSVersionInfoSize = Len(myOS)
GetVersionEx myOS
IsWinNT = (myOS.dwPlatformId = VER_PLATFORM_WIN32_NT)
End Function
 

Users who are viewing this thread

Back
Top Bottom