Forum Discussion
I'm troubling you again... have a question... :)
Below subroutine will call the function LastModifiedFle and get the excel file name(the one you helped me with), but I'm facing a problem here.
1. If I get the filename from Function to Subroutine, can I open the excel file using the below line...
Call Excel.Workbooks.Open("E:\Anil-Backup\Test Complete\Projects_Old\In4Suite Project\Exported Reports\" &LastModifiedFle)
I tried, but it is not recognizing the file, above line is reading only till folder Exported Reports, it is not taking &LastModifiedFle to read the filename, how to get this read the filename? TestResults zip file is attached for more details with screenshot in the .mht file. Code is below
Sub chek'Open Excel Connection
Dim LastModifiedFle
Set Excel = Sys.OleObject("Excel.Application")
Call Excel.Workbooks.Open("E:\Anil-Backup\Test Complete\Projects_Old\In4Suite Project\Exported Reports\" &LastModifiedFle) 'getting the filename from Function
Log.Message LastModifiedFle
chek Excel = .OleObject("Excel.Application") Excel.Workbooks.Open("E:\Anil-Backup\Test Complete\Projects_Old\In4Suite Project\Exported Reports\" &LastModifiedFle) .Message LastModifiedFle
End Sub
Function LastModifiedFle
Dim FolderName, FolderInfo, Num, i, FileDate, NewestTime, LatestFileIndex
FolderName = "E:\Anil-Backup\Test Complete\Projects_Old\In4Suite Project\Exported Reports"
Set FolderInfo = aqFileSystem.GetFolderInfo(FolderName)
Num = FolderInfo.Files.Count
Log.Message "The folder contains " &Num &" files."
NewestTime = aqDateTime.SetDateTimeElements(1000, 1, 1, 0, 0, 0)
LatestFileIndex = 0
For i = 0 to Num-1
FileDate = FolderInfo.Files.Item(i).DateLastModified
if(aqDateTime.Compare(NewestTime, FileDate) < 0) then
NewestTime = FileDate
LatestFileIndex = i
end if
Next
sPath = FolderInfo.Files.Item(LatestFileIndex).Path
fName = FolderInfo.Files.Item(LatestFileIndex).Name
Log.Message NewestTime &": " & sPath
Log.Message NewestTime &": " & fName
LastModifiedFle = fName 'I'm passing the excel filename to function and passing it to above subroutine
End Function
Related Content
- 2 years ago
Recent Discussions
- 3 days ago
- 4 days ago