Forum Discussion
I did following changes in the script... This time I'm getting "Type mismatch: 'LastModifiedFile'" error at line: ExlValue = LastModifiedFile
Function checkexcelcells()
checkexcelcells()
Dim ExlValue
ExlValue = LastModifiedFile 'Type mismatch: 'LastModifiedFile'" error at line, I tried giving () at end of LastModifiedFile(), still dint work :(
'Open Excel Connection
Set Excel = Sys.OleObject("Excel.Application")
' Call Excel.Workbooks.OpenXML("E:\Anil-Backup\Test Complete\Projects_Old\In4Suite Project\Exported Reports\"&ExlValue)
Set OpenExcel = Excel.Workbooks.OpenXML("E:\Anil-Backup\Test Complete\Projects_Old\In4Suite Project\Exported Reports\" &ExlValue)
Call OpenExcel 'Instead of Calling the excel directly (commented line above), used Set OpenExcel and calling OpenExcel
Delay 500
End Function
'===============================================================================
Sub LastModifiedFile() 'Added '( )' here
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
LastModifiedFile = fName
End Sub
Related Content
- 2 years ago
Recent Discussions
- 3 days ago
- 4 days ago