Search This Blog

Tuesday, January 18, 2011

Getting the number of files with same extension in a folder

Flag = 0
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder(sPath) 'Path of the folder
Set oFile = oFolder.Files
For each sFile in oFile
Pos = Instr(1,sFile.name,".jpeg",1) ' change the extn as required.
If Pos <> 0 Then
Flag =Flag +1
End If
Next
msgbox Flag

Monday, January 3, 2011

Reading data from a virtual table

This post will help you in reading data from a virtual table. This is really helpful and we took a very long time to come up with this solution. It is very simple but that thought process took some time to set in ;). So here we go.

Create the virtual table using the virtual objects manager. The properties available to you would be Width, Height, Rows, Columns, x, y.

Get the height and width of a single cell by dividing the table width and height by the column and row values respectively.

x and y are the values of the top left corner of the first cell, to get the bottom right corner add the height and width calculated for a single cell. Now use the GetVisibleText property with the parent object.

Like,
Say you have a grid or table that is recognized as a winobject, and you create a virtual table for it. Now the code to read the data from the first cell of the table would be:

val = Window(" ").Page(" ").WinObject(" ").GetVisibleText(x,y,x1,y1)
msgbox val