adspace


Hi,
I am USINg QTP tool for automation. Where VB Script have to
use. I want to read a row from the table present in .Doc
File and to paste in excel. Could you please assist me or
give me the code to get it. I am new in this technology.

Answer Posted / Navraj Singh Dharmshktu

To read data from a Word document and write it into an Excel file using QTP (QuickTest Professional) and VBScript, you can use the following steps:
1. Load Microsoft Word Application.
2. Open the desired Word Document.
3. Find the table you are interested in and get its reference.
4. Iterate through the rows of the table and extract the required data using 'Cell(rowNumber, columnNumber)' function.
5. Create a new Excel workbook or open an existing one.
6. Select the destination cell where you want to write the extracted data.
7. Write the data into the Excel cell using 'WriteExcel' function.nHere is a sample code:n```vbnSet IE = Browser("IE").GoToURL("http://yoururl.com/document.doc")nSet AppWord = CreateObject("Word.Application")nSet DocWord = AppWord.Documents.Open("D:document.doc")nSet TabWord = DocWord.Tables(1)nFor i = 1 To TabWord.Rows.CountnFor j = 1 To TabWord.Columns.CountnstrData = strData & TabWord.Cell(i,j).Text & " "nNext jnNext inSet AppExcel = CreateObject("Excel.Application")nSet WbkExcel = AppExcel.Workbooks.Add()nSet ShtExcel = WbkExcel.ActiveSheetnShtExcel.Cells(1, 1) = strDatanAppWord.Quit()nAppExcel.Visible = Truen```

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do I force a file dialogue box to reread the currect disk?

1529


With in the form we want to check all the text box control are typed or not? How?

2074


Draw Sequence Modal of DAO and Explain?

2145


Specify technical & functional architecture of your last 2 projects.

2149


How would you activate animation control?

2458


How would you attach pictures in column headers of List View Control?

2167


How do I make the mouse cursor invisible/visible?

1443


How do I tell when an application executed using the SHELL command is finished?

1645