Search code examples
excelqtphp-uft

How to take a control of specific cell of XL?


Below is my code to open XL file.

Set myxl = createobject("excel.application")

myxl.Workbooks.Open "E:\Employment.xls" 

myxl.Application.Visible = true

Here I am facing 1 issue. This code is able to open the XL file but it get displayed at task bar only. I am not able see the contents of xl file. refer attached screen shot for more details

2] My second issue is I want take a screenshot of 300th row and 8th column cell. I am able to read the data of this specific cell through UFT but cant scroll to this cell so that i can take screenshot of cell(300,8)


Solution

    1. You can open the excel in maximized mode as below:

      myxl.WindowState = -4137

    2. To scroll to cell (300,8), you can use the following:

      myxl.ActiveWindow.ScrollRow = 300

      myxl.ActiveWindow.ScrollColumn = 8

    Let me know if it worked or not.