VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "OpenSave"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit

Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Private Declare Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" (pOpenfilename As OPENFILENAME) As Long

Private Type OPENFILENAME
  lStructSize As Long
  hwndOwner As Long
  hInstance As Long
  lpstrFilter As String
  lpstrCustomFilter As String
  nMaxCustFilter As Long
  nFilterIndex As Long
  lpstrFile As String
  nMaxFile As Long
  lpstrFileTitle As String
  nMaxFileTitle As Long
  lpstrInitialDir As String
  lpstrTitle As String
  Flags As Long
  nFileOffset As Integer
  nFileExtension As Integer
  lpstrDefExt As String
  lCustData As Long
  lpfnHook As Long
  lpTemplateName As String
End Type

Private SaveFileDialog As OPENFILENAME
Private OpenFileDialog As OPENFILENAME

Private rv As Long
Private sv As Long
Private lFilter As String
Private lMaxFile As Long
Private lFlags As Long
Private lFile As String

Public Sub OpenFile(hwnd As Long, Caption As String)
   
With OpenFileDialog
 .lStructSize = Len(OpenFileDialog)
 .hwndOwner = hwnd
 .hInstance = App.hInstance
 .lpstrFilter = lFilter
 .lpstrFile = Space$(lMaxFile - 1)
 .nMaxFile = lMaxFile
 .lpstrFileTitle = Space$(lMaxFile - 1)
 .nMaxFileTitle = 255
 .lpstrInitialDir = App.Path
 .lpstrTitle = Caption
 .Flags = lFlags
End With

rv& = GetOpenFileName(OpenFileDialog)
If (rv&) Then lFile = Trim$(OpenFileDialog.lpstrFile) Else lFile = ""

End Sub

Public Sub SaveFile(hwnd As Long, Caption As String)
   
With SaveFileDialog
 .lStructSize = Len(OpenFileDialog)
 .hwndOwner = hwnd
 .hInstance = App.hInstance
 .lpstrFilter = lFilter
 .lpstrFile = Space$(lMaxFile - 1)
 .nMaxFile = lMaxFile
 .lpstrFileTitle = Space$(lMaxFile - 1)
 .nMaxFileTitle = 255
 .lpstrInitialDir = App.Path
 .lpstrTitle = Caption
 .Flags = lFlags
End With

sv& = GetSaveFileName(SaveFileDialog)
If (sv&) Then lFile = Trim$(SaveFileDialog.lpstrFile) Else lFile = ""

End Sub

Public Property Get MaxFile() As Long
MaxFile = lMaxFile
End Property

Public Property Let MaxFile(ByVal vNewValue As Long)
lMaxFile = vNewValue
End Property

Public Property Get Filter() As String
Filter = lFilter
End Property

Public Property Let Filter(ByVal vNewValue As String)
lFilter = vNewValue
End Property

Public Property Get Flags() As Long
Flags = lFlags
End Property

Public Property Let Flags(ByVal vNewValue As Long)
lFlags = vNewValue
End Property

Public Property Get File() As String
File = lFile
End Property

Public Property Let File(ByVal vNewValue As String)
lFile = vNewValue
End Property

Private Sub Class_Initialize()
lMaxFile = 255
End Sub
