If an Excel spreadsheet is not found then... - 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 Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners) +--- Thread: If an Excel spreadsheet is not found then... (/Thread-If-an-Excel-spreadsheet-is-not-found-then) |
If an Excel spreadsheet is not found then... - mv8167 - 03-16-2012 I am working on a function that the initial seeting of a ile bath is set to FaxFilePathName = "Empty". Depending on when a specific Test is run, either the FaxFilePathName variable is not "Empty", if "Empty" call Call CheckingFaxFilePathName () that will set the correct FaxFilePathName. If FaxFilePathName is not found, then exit the itteration as no file was ever created. I have the main part complete except the line: Code: Set objWorkbook = objExcel.WorkBooks.Open(FaxFilePathName) How can I check if a file exists or if not? My code: Code: If FaxFilePathName = "Empty" Then I think I figured it out: (let me know if this is bad coding) Code: Set objExcel = CreateObject("Excel.application") 'Create a new Microsoft Excel object RE: If an Excel spreadsheet is not found then... - sshukla12 - 03-16-2012 Hi, U can use FSO, it will help u out. Code: Set fso=CreateObject("Scripting.FileSystemObject") Regards, Sankalp RE: If an Excel spreadsheet is not found then... - mv8167 - 03-16-2012 Thx Sankalp, I must have read your mind. I completely forgot about doing this. Thx for confirming the code. ;-) Have a great weekend. Lorena RE: If an Excel spreadsheet is not found then... - sshukla12 - 03-21-2012 u r welcome.. |