Micro Focus QTP (UFT) Forums
How to Access MS Excel Controls using QTP - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: How to Access MS Excel Controls using QTP (/Thread-How-to-Access-MS-Excel-Controls-using-QTP)



How to Access MS Excel Controls using QTP - gayuamlu - 06-13-2015

Hi ,

Is there a way to access the MS Excel controls through QTP.
I want to refresh the Data in the Excel sheet and I tried to use the below code but in vain.

Code:
set xlo = createobject("Excel.Application")
Set xlbook = xlo.Workbooks.Open("XXXX")
xlo.Visible = true
Set xlsheet = xlbook.Worksheets(1)

xlo.CommandBars("Worksheet Menu Bar").Controls(7).controls(14).execute
Controls(7) - > Data tab in Ribbon
Controls(14)-> Refresh option

But this code throws "General run Error"

Please share your knowledge.