Qtp Script to find the number of occurences of a char in a string
Qtp Script to find the number of occurences of a char in a string-VB Script to find the number of occurences of a char in a string-QTP Scripts for beginners-VB Script
Qtp Script to find the number of occurences of a char in a string
qtp script to display string vertically-vb script to display string vertically-QTP Scripts-VB Scripts and QTP-QTP Examples-QTP
qtp script to display string vertically
Qtp Script to add an image to excel sheet-Qtp Script to insert an image into excel worksheet
Qtp Script to insert an image into excel worksheet
Set Excel = CreateObject("Excel.Application")
Excel.Visible = True
Set workbook = Excel.WorkBooks.Open("C:\abc.xls")
Set worksheet = workbook.Worksheets(1)
Excel.ActiveCell.Worksheet.Pictures.Insert("C:\image1.JPG")
QTP Script to delete all the worksheets except for the first worksheet-VB Script to delete all the worksheets except for the first worksheet
Set Excel = CreateObject("Excel.Application")
Excel.Visible = True
Set Workbook = Excel.Workbooks.Open("C:\qtp.xls")
i = Workbook.Worksheets.Count
Do Until i = 1
Workbook.Worksheets(i).Delete
i = i - 1
Loop
QTP Script to get name of all worksheets of an excel sheet-VB Script to get name of all worksheets of an excel sheet
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Set objWorkbook = objExcel.Workbooks.Open("C:\qtp.xls")
For Each objWorksheet in objWorkbook.Worksheets
Msgbox objWorksheet.Name
Next
Qtp Script to download attachments from outlook emails-VB Script to download attachments from outlook emails
Qtp Script to download attachments from outlook emails
QTP Script to read mails from inbox of outlook application-VB Script to read mails from inbox of outlook application
QTP Script to read mails from inbox of outlook application
QTP Script to get count of number of junk emails in outlook application-VB Script to get count of number of junk emails in outlook application
QTP Script to get count of number of junk emails in outlook application
Qtp Script to add an image to Ms Word Document-Qtp Script to insert an image into MS Word Document
Qtp Script to insert an image into MS Word Document
QTP Script to Find and Replace a Text in MS Word Document-Qtp Script to Replace a string in word document with another string
QTP Script to Count Number of Times a Word Appears in a Text File-VB Script to Count Number of Times a Word Appears in a Text File
QTP Script to Count Number of Times a Word Appears in a Text File
Const ForReading = 1
Set fso = CreateObject( "Scripting.FileSystemObject" )
Set textFile = fso.OpenTextFile( "C:\qtp.txt", ForReading )
contents = textFile.ReadAll
textFile.Close
Set rgxp = New Regexp
rgxp.Pattern = "QTP"
rgxp.IgnoreCase = True
rgxp.Global = True
Set matches = rgxp.Execute( contents )
Msgbox "Count = " & matches.Count
QTP Script to get type of file-VB Script to get type of file
QTP Script to get type of file
Set a = CreateObject("Scripting.FileSystemObject")
Set b = a.GetFile("C:\qtp.doc")
Msgbox b.Type
QTP Script to get size of folder-VB Script to get size of folder
QTP Script to get size of folder
Dim a,b
Set a = CreateObject("Scripting.FileSystemObject")
Set b = a.GetFolder("C:\QTP")
Msgbox b.size
QTP Script to get size of a text file-VB Script to get size of a text file
QTP Script to get size of a text file
Dim a,b
Set a = CreateObject("Scripting.FileSystemObject")
Set b = a.GetFile("C:\qtp.txt")
Msgbox b.size
Qtp script to get count of number of words in Ms Word Document-VB Script to get count of number of words in Ms Word Document
Qtp script to get count of number of words in Ms Word Document
set a=createobject("Word.Application")
a.visible=true
set b=a.Documents.open("C:\qtp.doc")
Msgbox "Number of Words = "& b.words.count
QTP Script to append an existing text file-VB Script to append an existing text file
QTP Script to append an existing text file
set a=CreateObject("Scripting.FileSystemObject")
set b=a.OpenTextFile("C:\qtp.txt",8)
b.WriteLine "New Text Added"
QTP Script to add a new line at the beginning of a text file-QTP Script to append a new line at the beginning of a text file
QTP Script to add a new line at the beginning of a text file-QTP Script to append a new line at the beginning of a text file
Const ForReading = 1
Const ForWriting = 2
fileName = "C:\qtp1.txt"
Set fso = CreateObject( "Scripting.FileSystemObject" )
Set textFile = fso.OpenTextFile(fileName, ForReading )
contents = textFile.ReadAll
textFile.Close
firstLine = "New Line Added"
newContent = firstLine & vbCrLf & contents
Set textFile = fso.OpenTextFile( fileName, ForWriting )
textFile.WriteLine newContent
QTP Script to append an existing MS Word document at the end of document-VB Script to append an existing MS Word document at the end of document
QTP Script to append an existing MS Word document at the end of document.
set a=createobject("Word.Application")
a.visible=true
a.Documents.open("C:\qtp.doc")
a.Selection.EndKey 6,0
a.Selection.TypeText "new text added at end"
a.ActiveDocument.Save
QTP Script to Find and Replace Text in a Text File-VB Script to Find and Replace Text in a Text File
QTP Script to Find and Replace Text in a Text File
Const ForReading = 1
Const ForWriting = 2
Set fso = CreateObject( "Scripting.FileSystemObject" )
Set textFile = fso.OpenTextFile( "C:\qtp.txt", ForReading )
Text = textFile.ReadAll
textFile.Close
NewText = Replace( Text, "abc", "QTP")
Set textFile = fso.OpenTextFile( "C:\qtp.txt", ForWriting )
textFile.WriteLine NewText
QTP Script to append an existing MS Word document at the beginning of document
QTP Script to append an existing MS Word document
set a=createobject("Word.Application")
a.visible=true
a.Documents.open("C:\qtp.doc")
a.Selection.TypeText "new text added"
a.ActiveDocument.Save
QTP Script to create Sub Folder within Folder-VB Script to create Sub Folder within Folder
QTP Script to create Sub Folder within Folder
Set fso = CreateObject("Scripting.FileSystemObject")
fso.createfolder("C:\Folder")
Set fso1 = fso.createfolder("C:\Folder\SubFolder1")
Msgbox("Folder and Subfolder Created")
QTP Script to open an existing MS Word document-VB Script to open an existing MS Word document
QTP Script to open an existing MS Word document
set a=createobject("Word.Application")
a.visible=true
a.Documents.open("C:\qtp.doc")
Sorting Data in Microsoft Excel through QTP-QTP Script to Sort Data in excel sheet in Descending Order
Sorting Data in Microsoft Excel through QTP-QTP Script to Sort Data in excel sheet in Descending Order
Const xlDescending = 2
Const xlYes = 2
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Set objWorkbook = objExcel.Workbooks.Open("C:\qtp.xls")
Set objWorksheet = objWorkbook.Worksheets(1)
Set objRange = objWorksheet.UsedRange
Set objRange2 = objExcel.Range("A1")
objRange.Sort objRange2,xlDescending, , , , , , xlYes
QTP Script to set the width of first column of an excel sheet-VB Script to set the width of first column of an excel sheet
QTP Script to set the width of first column of an excel sheet
dim a,b,c
set a=createobject("Excel.Application")
a.visible=true
set b=a.workbooks.open("C:\QTP.xls")
set c=b.worksheets(1)
c.Columns(1).ColumnWidth=50
QTP Script to set the Height of first row of an excel sheet-VB Script to set the Height of first row of an excel sheet
QTP Script to set the Height of first row of an excel sheet
dim a,b,c
set a=createobject("Excel.Application")
a.visible=true
set b=a.workbooks.open("C:\QTP.xls")
set c=b.worksheets(1)
c.Rows(1).RowHeight=50
QTP Script to copy one excel sheet data to other excel sheet-VB Script to copy one excel sheet data to other excel sheet
QTP Script to copy one excel sheet data to other excel sheet
Set excel=createobject("excel.application")
excel.Visible=True
Set workbook1=excel.Workbooks.Open("C:\qtp1.xls")
Set workbook2=excel.Workbooks.Open("C:\qtp2.xls")
workbook1.Worksheets("Lakshmi").usedrange.copy
workbook2.Worksheets("Sheet1").pastespecial
workbook1.Save
workbook2.Save
QTP Script to get count of unread mails in outlook-VB Script to get count of unread mails in outlook
QTP Script to get count of unread mails in outlook
Set a = CreateObject("Outlook.Application")
Set b = a.GetNameSpace("MAPI")
Set c = b.GetDefaultFolder(6)
Msgbox(c.UnreadItemCount)
QTP Script to add line numbers to MS Word document-VB Script to add line numbers to MS Word document
QTP Script to add line numbers to MS Word document
dim a
set a=createobject("Word.Application")
a.visible=true
set b=a.Documents.open("C:\qtp.doc")
b.PageSetup.LineNumbering.Active = TRUE
b.save
QTP Script to add Underlined text to MS Word document-VB Script to add Underlined text to MS Word document
QTP Script to add Underlined text to MS Word document
dim a
set a=createobject("Word.Application")
a.Documents.Add
a.visible=true
a.selection.font.size=20
a.selection.font.name="Times New Roman"
a.Selection.Font.Underline = 1
a.Selection.TypeText"HELLOOO"
a.ActiveDocument.Saveas"C:\qtp.doc"
QTP Script to Highlight First Row of an excel sheet-VB Script to Highlight First Row of an excel sheet
QTP Script to Highlight First Row of an excel sheet
dim a,b,c
set a=createobject("Excel.Application")
a.visible=true
set b=a.workbooks.open("C:\QTP.xls")
set c=b.worksheets(1)
c.Rows(1).Interior.ColorIndex= 6
QTP Script to Highlight First C0lumn of an excel sheet-VB Script to Highlight First Column of an excel sheet
QTP Script to Highlight First Column of an excel sheet
dim a,b,c
set a=createobject("Excel.Application")
a.visible=true
set b=a.workbooks.open("C:\QTP.xls")
set c=b.worksheets(1)
c.Columns(1).Interior.ColorIndex= 6
QTP Script to Highlight a cell in excel sheet-VB Script to Highlight a cell in excel sheet
QTP Script to Highlight a cell in excel sheet
dim a,b,c
set a=createobject("Excel.Application")
a.visible=true
set b=a.workbooks.open("C:\QTP.xls")
set c=b.worksheets(1)
c.Cells(1,1).Interior.ColorIndex= 6
QTP Script to change first cell font text to bold of an excel sheet-VB Script to change first cell font text to bold of an excel sheet.
QTP Script to change first cell font text to bold of an excel sheet.
dim a,b,c
set a=createobject("Excel.Application")
a.visible=true
set b=a.workbooks.open("C:\QTP.xls")
set c=b.worksheets(1)
c.Cells(1,1).Value="QTP"
c.Cells(1,1).Font.Bold=True
b.save
QTP Script to add bold text to word document-VB Script to add bold text to word document
QTP Script to add bold text to word document
dim a
set a=createobject("Word.Application")
a.Documents.Add
a.visible=true
a.selection.font.size=36
a.selection.font.name="Times New Roman"
a.selection.font.Bold=true
a.Selection.TypeText"HELLO"
a.ActiveDocument.Saveas"C:\qtp.doc"
QTP Script to Add Formatted Data to a Spreadsheet-QTP Script to change first cells font size,font name of an excel sheet
QTP Script to change first cells font size,font name of an excel sheet or QTP Script to Add Formatted Data to a Spreadsheet
dim a,b,c
set a=createobject("Excel.Application")
a.visible=true
set b=a.workbooks.open("C:\QTP.xls")
set c=b.worksheets(1)
c.Cells(1,1).Value="QTP"
c.Cells(1,1).Font.Size=16
C.Cells(1,1).Font.Name="Times New Roman"
b.save
qtp script to get name of nth worksheet of an excel sheet-vb script to get name of nth worksheet of an excel sheet
qtp script to get name of nth worksheet of an excel sheet
dim a,b
set a=createobject("Excel.Application")
a.visible=true
set b=a.workbooks.open("D:\abc.xls")
Msgbox b.sheets(1).Name
qtp script to get count of worksheets in an excel sheet-vb script to get count of worksheets in an excel sheet
qtp script to get count of worksheets in an excel sheet
dim a,b
set a=createobject("Excel.Application")
a.visible=true
set b=a.workbooks.open("D:\abc.xls")
Msgbox b.sheets.count
QTP Script to get count of number of drafts,number of sent mails,number of emails in Outbox and number of deleted items in outlook application
QTP Script to get count of number of drafts in outlook application
Set a = CreateObject("Outlook.Application")
Set b = a.GetNameSpace("MAPI")
Set c = b.GetDefaultFolder(16)
msgbox(C.Items.Count)
QTP Script to get count of number of sent mails in outlook application
Set a = CreateObject("Outlook.Application")
Set b = a.GetNameSpace("MAPI")
Set c = b.GetDefaultFolder(5)
msgbox(C.Items.Count)
QTP Script to get count of number of emails in Outbox of outlook application
Set a = CreateObject("Outlook.Application")
Set b = a.GetNameSpace("MAPI")
Set c = b.GetDefaultFolder(4)
msgbox(C.Items.Count)
QTP Script to get count of number of deleted items in outlook application
Set a = CreateObject("Outlook.Application")
Set b = a.GetNameSpace("MAPI")
Set c = b.GetDefaultFolder(3)
msgbox(C.Items.Count)
QTP Script to read the entire contents of a text file-VB Script to read the entire contents of a text file
QTP Script to read the entire contents of a text file
Dim a,b
Const ForReading = 1
Set a=CreateObject( "Scripting.FileSystemObject" )
Set b=a.OpenTextFile( "C:\qtp.txt",1)
Msgbox b.Readall
qtp script to read first few characters of a text file-vb script to read first few characters of a text file
qtp script to read first few characters of a text file
Dim a,b
Const ForReading = 1
Set a=CreateObject( "Scripting.FileSystemObject" )
Set b=a.OpenTextFile( "C:\qtp.txt",1)
Msgbox b.Read(5)
qtp script to read first line of a text file-vb script to read first line of a text file
qtp script to read first line of a text file
Dim a,b
Const ForReading = 1
Set a=CreateObject( "Scripting.FileSystemObject" )
Set b=a.OpenTextFile( "C:\qtp.txt",1)
Msgbox b.Readline
qtp script to insert blank lines into text file-vb script to insert blank lines into text file
qtp script to insert blank lines into text file
Dim a,b
Set a=CreateObject("Scripting.FileSystemObject")
Set b=a.CreateTextFile("c:\qtp.txt", True)
b.WriteLine("hiii")
b.WriteBlankLines(5)
b.WriteLine ("helloooo")
b.Close
qtp script to read last line of a text file-vb script to read last line of a text file
qtp script to read last line of a text file
Dim a,b,c
Set a = CreateObject("Scripting.FileSystemObject")
Set b = a.opentextfile("C:\qtp.txt", 1)
i = 0
Do While b.AtEndOfStream <> True
c = b.ReadLine
i = i + 1
Loop
MsgBox c
QTP Script to count number of lines in a text file-VB Script to count number of lines in a text file
QTP Script to count number of lines in a text file.
Dim a,b
Const ForReading = 1
Set a=CreateObject( "Scripting.FileSystemObject" )
Set b=a.OpenTextFile( "C:\qtp.txt",1)
b.ReadAll
Msgbox "Number of lines= " & b.Line
QTP Script to get count of number of mails in outlook application-VB Script to get count of number of mails in outlook application
QTP Script to get count of number of mails in outlook application
Set a = CreateObject("Outlook.Application")
Set b = a.GetNameSpace("MAPI")
Set c = b.GetDefaultFolder(6)
msgbox(C.Items.Count)
qtp script to get message box text in 2 lines-vb script to get message box text in two lines
qtp script to get message box text in two lines
MsgBox ("Hi" & vbCrLf & "Hello")
Output-
Hi
Hello
QTP Script to display Message Box Text in Multiple Lines-VB Script to get message box text in multiple lines
qtp script to get message box text in multiple lines
MsgBox ("Line1" & vbCrLf & "Line2" & vbCrLf & "Line3" & vbCrLf & "Line4" & vbCrLf & "Line5")
Output -
Line1
Line2
Line3
Line4
Line5
QTP Script to get version of Outlook-VB Script to get version of Outlook
QTP Script to get version of Outlook
dim a
set a=createobject("Outlook.Application")
Msgbox(a.version)
QTP Script to open Outlook -VB Script to open Outlook
QTP Script to open Outlook
dim a,b,c
Set a = CreateObject("Outlook.Application")
Set b = a.GetNamespace("MAPI")
Set c=b.GetDefaultFolder(3)
c.Display
Msgbox("Outlook Opened")
QTP Script to sort excel sheet column-VB Script to sort excel sheet column
QTP Script to sort excel sheet column
dim a,b,c,d
set a=createobject("Excel.Application")
a.visible=true
set b=a.workbooks.open("D:\abc.xls")
set c=b.worksheets(1)
set d=c.usedrange
d.sort(d)
QTP Script to delete first two columns data of excel sheet-VB Script to delete first two columns data of excel sheet
QTP Script to delete first two columns data of excel sheet
dim a,b,c,d
set a=createobject("Excel.Application")
a.visible=true
set b=a.workbooks.open("D:\abc.xls")
set c=b.worksheets(1)
c.Columns("A:B").Delete
QTP Script to copy one worksheet data of Excel Sheet to other worksheet-VB Script to copy one worksheet data of Excel Sheet to other worksheet
QTP Script to copy one worksheet data of Excel Sheet to other worksheet
dim a,b
set a=createobject("Excel.Application")
a.visible=true
set b=a.workbooks.open("D:\abc.xls")
b.sheets("sheet1").Copy,b.Sheets(1)
b.save
Creats copy of sheet1 in new excel worksheet
QTP Script to Change(Move) worksheets position of Excel Sheet-VB Script to Change(Move) worksheets position of Excel Sheet
QTP Script to Change(Move) worksheets position of Excel Sheet
dim a,b,c
set a=createobject("Excel.Application")
a.visible=true
set b=a.workbooks.open("D:\abc.xls")
b.sheets("sheet1").Move,b.Sheets(2)
b.save
QTP Script to delete top two rows of excel sheet-VB Script to delete top two rows of excel sheet-QTP-Excel Sheet
QTP Script to delete top two rows of excel sheet
dim a,b,c
set a=createobject("Excel.Application")
a.visible=true
set b=a.workbooks.open("D:\abc.xls")
set c=b.worksheets("sheet1")
c.rows("1:2").delete
b.save
QTP Script to delete worksheet of Excel Sheet-VB Script to delete worksheet of Excel Sheet-QTP Scripts-Excel Sheet
QTP Script to delete worksheet of Excel Sheet
dim a,b
set a=createobject("Excel.Application")
a.visible=true
set b=a.workbooks.open("D:\abc.xls")
b.Sheets("lax").delete
b.save
QTP Script to rename Excel Worksheet-VB Script to rename Excel Worksheet-QTP-Excel Sheet-Excel Sheet-QTP
QTP Script to rename Excel Worksheet
dim a,b
set a=createobject("Excel.Application")
a.visible=true
set b=a.workbooks.open("D:\abc.xls")
b.worksheets(1).name="lax"
b.save
QTP Script to add new worksheet to Excel Sheet -VB Script to add new worksheet to Excel Sheet-QTP -Excel Sheet
QTP Script to add new worksheet to Excel Sheet
dim a,b,c
set a=createobject("Excel.Application")
a.visible=true
set b=a.workbooks.open("D:\abc.xls")
set c=b.sheets.add
b.save
QTP Script to send mails from outlook to multiple persons-QTP Script to send mails from outlook to more than one person-QTP Scripts
QTP Script to send mails from outlook to more than one person
dim a,b
set a=createobject("Outlook.Application")
set b=a.createitem(0)
b.to="lakshmi@abc.com"
b.cc="lak@xyz.com"
b.bcc="lax@aaa.com"
b.subject="hello"
b.body="hiiiii"
b.send
MsgBox("Mail Sent To All")
QTP Script to send email with an attachment through Outlook-VB Script to send email with an attachment from Outlook
QTP Script to send email with an attachment from Outlook
dim a,b
set a=createobject("Outlook.Application")
set b=a.createitem(Mail)
b.to="abc@xyz.com"
b.subject="hello"
b.body="hiiiii"
b.attachments.add"C:\Documents and Settings\lakshmi\Desktop\qtp.txt"
b.send
QTP Script to close Outlook-VB Script to close Outlook-QTP and Outlook-VB Script and Outlook
QTP Script to close Outlook
First Open Outlook and run the below script
dim a
set a=createobject("Outlook.Application")
a.quit
MsgBOx("Outlook Closed")
QTP Script to send mail from outlook-VB Script to send mail from outlook
QTP Script to send mail from outlook
dim a,b
set a=createobject("Outlook.Application")
set b=a.createitem(Mail)
b.to="lakshmi@abc.com"
b.subject="hello"
b.body="hiiiii"
b.send
Qtp Script to display Time in different formats-VB Script to display Time in different formats
Qtp Script to display Time in different formats
Dim a
a=FormatDateTime(Now(),vbLongTime)
MsgBox(a)
Output-4:33:08 PM
Dim a
a=FormatDateTime(Now(),vbShortTime)
MsgBox(a)
Output-16:33
QTP Script to display date in different formats-VB Script to display date in different formats
QTP Script to display date in different formats
Dim a
a=FormatDateTime(Date(),vbGeneralDate)
MsgBox(a)
Output-8/8/2012
Dim a
a=FormatDateTime(Date(),vbLongDate)
MsgBox(a)
Output-Wednesday, August 08, 2012
Dim a
a=FormatDateTime(Date(),vbShortDate)
MsgBox(a)
Output-8/8/2012
QTP Script To Get Abbreviated Name of Current Month-VB Script To Get Abbreviated Name of Current Month
QTP Script To Get Abbreviated Name of Current Month
Dim a
a=MonthName(Month(Date),True)
MsgBox(a)
Output-Aug
QTP Script To Get Abbreviated Name of Month-VB Script To Get Abbreviated Name of Month
QTP Script To Get Abbreviated Name of Month
Dim a
a=MonthName(1,true)
MsgBox(a)
Output-Jan
Dim a
a=MonthName(2,true)
MsgBox(a)
Output-Feb
QTP Script To Get Abbreviated Name of Current Weekday-VB Script To Get Abbreviated Name of Current Weekday
QTP Script To Get Abbreviated Name of Current Weekday
Dim a
a=WeekDayName(Weekday(date),true)
MsgBox(a)
Output-Wed
QTP Script To Get Abbreviated Name of Weekday-VB Script To Get Abbreviated Name of Weekday
QTP Script To Get Abbreviated Name of Weekday
Dim a
a=WeekDayName(1,true)
MsgBox(a)
Output-Sun
Dim a
a=WeekDayName(2,true)
MsgBox(a)
Output-Mon
QTP Script to Get Last Modified Date and Time of a Folder-VB Script to Get Last Modified Date and Time of a Folder
QTP Script to Get Last Modified Date and Time of a Folder-VB Script to Get Last Modified Date and Time of a Folder
How to get Last Modified date and time of a particular folder?
Dim a,b,c
Set a = CreateObject("Scripting.FileSystemObject")
Set b = a.GetFolder("C:\QTP")
c= "Folder was Last Modified on: " & b.DateLastModified
MsgBox(c)
QTP Script to Get Accessed Date and Time of a Folder-VB Script to Get Accessed Date and Time of a Folder
How to get Last Accessed date and time of a particular folder?
Dim a,b,c
Set a = CreateObject("Scripting.FileSystemObject")
Set b = a.GetFolder("C:\QTP")
c= "Folder was Accessed last on: " & b.DateLastAccessed
MsgBox(c)
QTP Script to Get Created Date and Time of a folder-vb script to get Created Date and Time of a folder
QTP Script to get folder created time
Dim a,b,c
Set a = CreateObject("Scripting.FileSystemObject")
Set b = a.GetFolder("C:\QTP")
c= "Folder was Created on: " & b.DateCreated
MsgBox(c)
above script displays created date and time of qtp folder,which is in C Drive.
QTP Script to delete folder-VB Script to delete folder in system-Delete Folder QTP Script-QTP File System Object
dim a
set a=createobject("scripting.filesystemobject")
a.deletefolder("d:\\xyz")
MsgBox("Folder Deleted")