using Word.Document's SaveAs Function (VB6)
-
Hey, I'm trying to save a file with the SaveAs function under the Word.Document... However, if I have a file of the same name, it simply overwrites without giving me a prompt to do so.. Is there any way around this? I checked the list of parameters, and none of them give like, a boolean for 'SaveOverride' or whatever. Thanks. --- reegan41
-
Hey, I'm trying to save a file with the SaveAs function under the Word.Document... However, if I have a file of the same name, it simply overwrites without giving me a prompt to do so.. Is there any way around this? I checked the list of parameters, and none of them give like, a boolean for 'SaveOverride' or whatever. Thanks. --- reegan41
According to the SaveAs help documentation the default behaviour is to overwrite without prompting. What you can do is test to see if the file your are going to save as already exists, and then do something to select another name. In the code example below, if the file "c:\test.doc" exists the while loop will try for "c:\test_1.doc". If that file exists, it will then try for "c:\test_2.doc" and so on.
Dim I As Long Dim SaveAsFileName As String Dim NewSaveAsFileName As String SaveAsFileName = "c:\Test.doc" NewSaveAsFileName = SaveAsFileName While Dir(NewSaveAsFileName, vbNormal) <> "" I = I + 1 NewSaveAsFileName = Left(SaveAsFileName, Len(SaveAsFileName) - 4) & "_" & i & _ Right(SaveAsFileName, 4) Wend