Count number of tabs in Excel with UFT

  • Questions
  • Count number of tabs in Excel with UFT
Question ID: 107724
0
0

I’m using UFT to compare to Excel workbooks. I need to count the number of tabs in each worksheet. Using ‘excelObj.WorkbookName.Sheets.Count’ is returning more tabs than the number of tabs that are there. Is it counting deleted tabs or something?

Marked as spam
Posted by (Questions: 162, Answers: 22)
Asked on July 18, 2017 5:13 pm
4 views
Answers
0
Private answer

It's probably seeing hidden tabs that exist in the workbook. Here's a sample of some code that you can use that will count the number of visible and hidden tabs so you can see a count of each. You can take the code a step further and use the visible count variable in your script for the value of the number of visible tabs displayed and this should return the correct number you want:

For i = 1 To excelObj.WorkbookName.Sheets.Count
visibleCount=0
invisibleCount=0
If Not excelObj.WorkbookName.Sheets(i).Visible Then
invisibleCount=invisibleCount+1
Else
visibleCount=visibleCount+1
End If
Next

MsgBox ''Visible Tabs Count: ''& visibleCount & '' Invisible Tabs Count: ''& invisibleCount

Marked as spam
Posted by (Questions: 2, Answers: 412)
Answered on July 18, 2017 5:17 pm