01-12-2011, 07:26 PM
Hello All,
I was going thorugh the MS Word automation article by Saket in this site.
I tried running the code below twice
For the first run it saved the file as test.doc under C drive with Hello World!!! written inside it.
During the second run insted of "Hello World", I put "My India" and the content was overwritten.
Now my question is, we have used "SavedAs" method to save a file in both run. For the 1st run the file gets created but for the 2nd run it should have thrown error for we are trying to save
another file having same name under the same directory. But it didn't. It just overwrote the file. So here "SaveAs" method worked as "Save" method.
Does "SaveAs" method implicitly says to overwrite an existing file?? If no what is the reason here??
Thanks!!!!
I was going thorugh the MS Word automation article by Saket in this site.
I tried running the code below twice
Code:
Dim oWord Set oWord = CreateObject("Word.Application")
oWord.Documents.Add
oWord.Selection.TypeText "Hello World!!!"
oWord.ActiveDocument.SaveAs "c:\test.doc"
oWord.Quit
Set oWord = Nothing
For the first run it saved the file as test.doc under C drive with Hello World!!! written inside it.
During the second run insted of "Hello World", I put "My India" and the content was overwritten.
Now my question is, we have used "SavedAs" method to save a file in both run. For the 1st run the file gets created but for the 2nd run it should have thrown error for we are trying to save
another file having same name under the same directory. But it didn't. It just overwrote the file. So here "SaveAs" method worked as "Save" method.
Does "SaveAs" method implicitly says to overwrite an existing file?? If no what is the reason here??
Thanks!!!!