Custom Search

Wednesday, October 31, 2012

How to return "working" from "I am working in on office" string

str= "I am working in on office"
strsearch="working"
msgbox mid(str,instr(1,str,strsearch),Len(strsearch))

Thursday, October 25, 2012

How to get Subject and body from the Outlook mail


set olApp=createObject("Outlook.Application")
set olns=olApp.GetNameSpace("MAPI")
set objFolder=olns.GetDefaultFolder(6)
for each item1 in objFolder.items
if item1.unread then
msgbox item1.subject
msgbox item1.body
end if
next

Monday, October 22, 2012

How to Restart computer through VBScript\QTP

strComputer = "ComputerName"
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate,(Shutdown)}!\\" & _
        strComputer & "\root\cimv2")

Set colOperatingSystems = objWMIService.ExecQuery _
    ("Select * from Win32_OperatingSystem")

For Each objOperatingSystem in colOperatingSystems
    objOperatingSystem.Reboot()
Next

How to Import\Download attachment files from QC Test Plan to local Drive


LocalFilePath = "C:\Updated_Files_Form_QC_TillDate"
Set QCConnection = QCUtil.QCConnection
Set treeManager = QCConnection.TreeManager
'Specify the Quality Center path to the desired folder
QC_Path ="Subject\Automation\Regression\Library"
Set node = treeManager.nodebypath(QC_Path)
set stratt = node.attachments
For Each obj_QCAttachment In stratt.NewList("")
      Set obj_QCAttachmentStorage = obj_QCAttachment.AttachmentStorage
      obj_QCAttachmentStorage.ClientPath = LocalFilePath 'give the directory where u want to save the file
      obj_QCAttachmentStorage.Load obj_QCAttachment.Name,True
Next

Wednesday, October 3, 2012

How to find length of the string without using Len function

str="FindLength"
'Here you need to add one single character which is not existed in your string
str=FindLengthr"
'here i had added one character "r" in the last of the string
msgbox instr(1,str,"r",1)-1

OtherWay:
str="VBSCRIPTING"
i=1
do
str1=mid(str,i,1)
if str1<>"" then
i=i+1
else
exit do
end if
loop until str1=""
msgbox i-1

How to verify some text in Excel which is having large number of data

Set xl=CreateObject("Excel.Application")
xl.Workbooks.Open "C:\Test.xlsx"
Set r = xl.Range("A1:N20").Find("kamesh")
If r Is Nothing Then
xl.Cells(1,1).Value= "not found"
Else
xl.Cells(1,1).Value= "found"
End If
xl.quit
set xl=nothing