S
singeredel
Below is the code I have that checks to see if the file name already exists
and, if so, provides an input box to put in a different file name before
saving. The problem I have with this is the Cancel button on the input box
just erases the string text that was already placed in the input box (the
file name being duplicated). I would like to know how to actually cancel out
of the input box and stop the code from executing when I just want to quit
the whole process.
If there is a better way of accomplishing the checking for a duplicate file
name and being able to replace it with a modified file name (or exiting the
whole process altogether), that would be appreciated too.
Thanks...
SaveFile:
Dim TestFile As String
TestFile = Dir(SaveCurrentFile)
If Len(TestFile) = 0 Then
ActiveDocument.SaveAs (SaveCurrentFile), FileFormat:= _
wdFormatDocument
'ChDir DictationDateFolder
ChangeFileOpenDirectory (DictationDateFolder)
GoTo MakeHeader2
Else:
FileExists:
Dim ResponseFileExists As String 'VbMsgBoxResult
ResponseFileExists = InputBox("The file name " + SaveCurrentFile +
Chr(13) + _
"already exists in the current directory" + Chr(13) + Chr(13) + _
"Type new file name below:", "FileExists", SaveCurrentFile)
SaveCurrentFile = ResponseFileExists
GoTo SaveFile
End If
and, if so, provides an input box to put in a different file name before
saving. The problem I have with this is the Cancel button on the input box
just erases the string text that was already placed in the input box (the
file name being duplicated). I would like to know how to actually cancel out
of the input box and stop the code from executing when I just want to quit
the whole process.
If there is a better way of accomplishing the checking for a duplicate file
name and being able to replace it with a modified file name (or exiting the
whole process altogether), that would be appreciated too.
Thanks...
SaveFile:
Dim TestFile As String
TestFile = Dir(SaveCurrentFile)
If Len(TestFile) = 0 Then
ActiveDocument.SaveAs (SaveCurrentFile), FileFormat:= _
wdFormatDocument
'ChDir DictationDateFolder
ChangeFileOpenDirectory (DictationDateFolder)
GoTo MakeHeader2
Else:
FileExists:
Dim ResponseFileExists As String 'VbMsgBoxResult
ResponseFileExists = InputBox("The file name " + SaveCurrentFile +
Chr(13) + _
"already exists in the current directory" + Chr(13) + Chr(13) + _
"Type new file name below:", "FileExists", SaveCurrentFile)
SaveCurrentFile = ResponseFileExists
GoTo SaveFile
End If