Tom Keatley
tomk at multiline.com.au
Sat Nov 8 17:57:28 CST 2003
Hi all... I am using the code below to bring up a standard file dialogue in Windows to select a file for import which works GREAT. I would like however the dialogue to appear in the centre of the form it is being called from. I believe this will have something to do with the HWND but have no idea how to proceed from here. Can anyone assist ? Function APIDialogBox() Dim OpenFile As OPENFILENAME Dim lReturn As Long Dim sFilter As String OpenFile.lStructSize = Len(OpenFile) 'OpenFile.hwndOwner = me.Hwnd 'OpenFile.hInstance = App.hInstance sFilter = "Pied Piper Order Files (*.eml)" & Chr(0) & "*.eml" & Chr(0) _ & "OLD Pied Piper Order Files (*.XXX)" & Chr(0) & "*.XXX" & Chr(0) _ & "All Files (*.*)" & Chr(0) & "*.*" & Chr(0) 'sFilter = "All Files (*.*)" & Chr(0) & "*.*" & Chr(0) OpenFile.lpstrFilter = sFilter 'OpenFile.nFilterIndex = 1 OpenFile.lpstrFile = String(257, 0) OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1 OpenFile.lpstrFileTitle = OpenFile.lpstrFile OpenFile.nMaxFileTitle = OpenFile.nMaxFile OpenFile.lpstrInitialDir = "C:\_WebOrders\" OpenFile.lpstrTitle = "Please Select a Web Order" OpenFile.flags = 0 lReturn = GetOpenFileName(OpenFile) If lReturn = 0 Then APIDialogBox = "" Else APIDialogBox = Trim(OpenFile.lpstrFile) 'gives me pathname\filename OrdFilNam = OpenFile.lpstrFile 'gives me filename filnam = OpenFile.lpstrFileTitle 'gives me path\ PthNam = Left(OpenFile.lpstrFile, OpenFile.nFileOffset) 'Call WEBIMPORT End If End Function