Tyke
23rd Sep 2010, 02:07 pm
I have the situation where the insertion points of a number of circles are written to an ASCII file for use in another programm. A filename is automatically sugested and if the user accepts it the file is saved, overwriting any existing file with the same name, if it exists and without displaying an alert message, eg "Do want to overwrite the existing file?".
Hers's the code for the function that I'm currently using
Public Function ShowSave(Filter As String, _
InitialDir As String, _
DialogTitle As String) As String
Dim SFName As SAVEFILENAME
ShowSave = ""
' suggest a file name
SFName.lpstrFile = strAsciiFileName
'Set the structure size
SFName.lStructSize = Len(SFName)
'Set the owner window
SFName.hwndOwner = 0
'Set the filter
SFName.lpstrFilter = Filter
'Set the maximum number of chars
SFName.nMaxFile = 255
'Create a buffer
SFName.lpstrFileTitle = strAsciiFileName
'Set the maximum number of chars
SFName.nMaxFileTitle = 255
'Set the initial directory
SFName.lpstrInitialDir = InitialDir
'Set the dialog title
SFName.lpstrTitle = DialogTitle
'no extra flags
SFName.flags = 0
'Show the 'SaveAs File’ dialog
If GetSaveFileName(SFName) Then
ShowSave = Trim(SFName.lpstrFile)
Else
ShowSave = "QUIT"
End If
End Function
Is it possible to easily implement such an alert?
Hers's the code for the function that I'm currently using
Public Function ShowSave(Filter As String, _
InitialDir As String, _
DialogTitle As String) As String
Dim SFName As SAVEFILENAME
ShowSave = ""
' suggest a file name
SFName.lpstrFile = strAsciiFileName
'Set the structure size
SFName.lStructSize = Len(SFName)
'Set the owner window
SFName.hwndOwner = 0
'Set the filter
SFName.lpstrFilter = Filter
'Set the maximum number of chars
SFName.nMaxFile = 255
'Create a buffer
SFName.lpstrFileTitle = strAsciiFileName
'Set the maximum number of chars
SFName.nMaxFileTitle = 255
'Set the initial directory
SFName.lpstrInitialDir = InitialDir
'Set the dialog title
SFName.lpstrTitle = DialogTitle
'no extra flags
SFName.flags = 0
'Show the 'SaveAs File’ dialog
If GetSaveFileName(SFName) Then
ShowSave = Trim(SFName.lpstrFile)
Else
ShowSave = "QUIT"
End If
End Function
Is it possible to easily implement such an alert?