Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to get row count if xls file is generating dynamically.
#3
Solved: 10 Years, 9 Months, 1 Week ago
Hi,

My Assumptions:

Excel file name is changing dynamically and saving this filie in specific folder (Make sure that folder name is not varying)

From the above what i am trying to say is whatever the excel file name that will be saved in a specific folder with this

We would fetch the last modified file name that is the excel file which it is modified in that specific folder that means after saving this file in specific folder the excel file name becomes the last modified file name.Once you fetch this then u could use the datatable.Import (Last modified file name).
Once u imported this to data table then u could find out the row count using Datatable.GetRowcount


Please find the below code to fetch the last modified file name in specific folder.

Code:
Function GetNewestFile(ByVal sPath)

   sNewestFile = Null   ' init value

   Set oFSO = CreateObject("Scripting.FileSystemObject")
   Set oFolder = oFSO.GetFolder(sPath)
   Set oFiles = oFolder.Files

   ' enumerate the files in the folder, finding the newest file
   For Each oFile In oFiles
     On Error Resume Next
     If IsNull(sNewestFile) Then
       sNewestFile = oFile.Path
       dPrevDate = oFile.DateLastModified
     Elseif dPrevDate < oFile.DateLastModified Then
       sNewestFile = oFile.Path
     End If
     On Error Goto 0
   Next

   If IsNull(sNewestFile) Then sNewestFile = ""

   GetNewestFile = sNewestFile

End Function
sPath = "c:\my test"  'Here my test is the folder name
Set oFSO = CreateObject("Scripting.FileSystemObject")
sNewestFile = GetNewestFile(sPath)
If sNewestFile <> "" Then
   WScript.Echo "Newest file is " & sNewestFile
Else
   WScript.Echo "Directory is empty"
End If

Please let me know for further clarification.

Regards,
Venkat.Batchu
Reply


Messages In This Thread
RE: How to get row count if xls file is generating dynamically. - by venkatbatchu - 08-18-2010, 06:15 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to dynamically find the OracleFormWindow? arpan 0 1,506 04-26-2017, 12:45 AM
Last Post: arpan
  How to click on all links dynamically in UFT? Rohan 9 17,924 02-25-2016, 10:42 AM
Last Post: vinod123
  Searching for and selecting row in Datawindow zsl0009 0 2,677 08-04-2015, 01:02 AM
Last Post: zsl0009
  How to Verify Static Object Text which is changing Dynamically with Expected Result johnny77 0 3,188 06-25-2015, 11:32 AM
Last Post: johnny77
  SAPGuiSession get the active SAPGuiWindow dynamically cko77 2 5,154 01-27-2014, 12:04 PM
Last Post: cko77

Forum Jump:


Users browsing this thread: 2 Guest(s)