Micro Focus QTP (UFT) Forums
Export to Excel Error with file being open - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Regular Expressions (https://www.learnqtp.com/forums/Forum-UFT-QTP-Regular-Expressions)
+--- Thread: Export to Excel Error with file being open (/Thread-Export-to-Excel-Error-with-file-being-open)



Export to Excel Error with file being open - schulerswanie - 07-09-2012

I have a test I am running that exports data to Excel. The first time I run the test it creates the file no problem but then when it loops through for the second time it hits this code and errors out saying The DataTable.Export (file) operation failed.
Cannot open the D:\CDC-Automation\Data\Iteration1\Build5_7\Target\Target_Scan_URL.xls file because it is already open in another application.

Function file: D:\CDC-Automation\CDC_QTP_MAIN\Function Libraries\CDC_functions.qfl
Line (694): " datatable.export Target_file".

If instr(url_location,"Source") <> 0 then Source_file=file_dir & "Source_Scan_" & file_name
datatable.export Source_file
elseif instr(url_location,"Target")<> 0 then]
Target_file =file_dir & "Target_Scan_" & file_name Source_file=Replace(Target_file, "Target", "Source") datatable.export Target_file
end if

Any suggestions?


RE: Export to Excel Error with file being open - sshukla12 - 07-10-2012

Hi,

In 2nd run error msg is coming,do u want to overwrite the sheet or append it?

Regards,
Sankalp


RE: Export to Excel Error with file being open - Ankesh - 07-10-2012

This is a known issue... There is a workaround for this provided by HP.

Please check the below site.

http://automatingsap.blogspot.in/2012/07/general-error-when-exportimport.html

Regards,
Ankesh