Ask a Question

Save a Word File

Madhi
Contributor

Save a Word File

My application invokes a report in word file format.

TC should save it in a folder.  I create the folder using aqfilesystem. 

Is there a builtin function to enter some data in the word file and save the it in the specified folder?
2 REPLIES 2
YMinaev
Staff

Hi,



Here is sample code:



function WriteTextToDOC(input, output, text)

{

var WordObject = Sys.OleObject("Word.Application");

WordObject.Documents.Open(input);

WordObject.ActiveDocument.Content = text;

WordObject.ActiveDocument.SaveAs(output);

WordObject.ActiveDocument.Close();

WordObject.Quit();

WordObject = null;

while (Sys.WaitProcess("WINWORD", 500).Exists) {

Delay(500);

}

}



// ...

WriteTextToDOC('c:\\input.doc', 'c:\\output.doc', 'Sample Text');

// ...

------
Yuri
TestComplete Customer Care Engineer

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Madhi
Contributor

Thank you very much.
cancel
Showing results for 
Search instead for 
Did you mean: