View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
GS[_6_] GS[_6_] is offline
external usenet poster
 
Posts: 1,182
Default Question about ActiveWorkbook.SaveAs()

Alternatively, you can check if the workbook is saved and if not prompt
the use with your own alert...

Dim vRet

If FileExists("myfile.xlsm") Then
vRet = MsgBox("A file named 'myfile.xlsm' already exists in this
location. Do you want to replace it?", vbYesNo)

If vRet = vbYes Then
'do this
Else
'do that
End If



Public Function FileExists(Filename$) As Boolean
Dim nAttr As Long
' Grab this files attributes, and make sure it isn't a folder.
' This test includes cases where file doesn't exist at all.
nAttr = GetFileAttributes(Filename)
If (nAttr And vbDirectory) < vbDirectory Then
FileExists = True
ElseIf Err.LastDllError = ERROR_SHARING_VIOLATION Then
FileExists = True
End If
End Function 'FileExists()

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion