Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Word Doc Automation
#1
Not Solved
Hello All,

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!!!!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  UFT Word automation wannel 1 2,322 10-31-2016, 06:59 PM
Last Post: wannel
  How to Export run result viewer with CAPTURED DATA and save it in PDF,or Doc,or HTML akhandesh 0 2,951 07-16-2015, 06:03 PM
Last Post: akhandesh
  QTP 11- Help DOC(Support) for SAP NetWeaver Applications amar99 3 3,499 06-10-2013, 11:23 PM
Last Post: jumplevels
  Search for a word in excel string QAVA 6 9,306 11-23-2012, 11:17 AM
Last Post: vinod123
  Search for a word in string QAVA 5 4,469 11-22-2012, 04:50 PM
Last Post: Saleel Prabhu

Forum Jump:


Users browsing this thread: 2 Guest(s)