Re: Getting error while running below code in excel macros (200 Views)
Reply
Occasional Advisor
panki
Posts: 12
Registered: ‎01-07-2014
Message 1 of 4 (234 Views)

Getting error while running below code in excel macros

Hi,

 

I an running below code in Excel macros but receiving the error "Run-time error '91'Object variable or with block variable not set." I am not able to find out what is the problem. can anybody suggest me the solution?

PFB the code

 

Public Sub TSTestProperties()


Set QCConnection = CreateObject("TDApiOle80.TDConnection")
Dim sUserName, sPassword
sUserName = "User name"
sPassword = "password"
QCConnection.InitConnectionEx "ALM link"
QCConnection.Login sUserName, sPassword

If (QCConnection.LoggedIn <> True) Then
MsgBox "QC User Authentication Failed"
WScript.Quit
End If

Dim sDomain, sProject
sDomain = "Domain"
sProject = "Project"

QCConnection.Connect sDomain, sProject

If (QCConnection.Connected <> True) Then
MsgBox "QC Project Failed to Connect to " & sProject
WScript.Quit
End If
   
    Dim TestSetFact ' As TestSetFactory
    Dim TSTestFact 'As TSTestFactory
    Dim theTestSet 'As TestSet
    Dim theTSTest  'As TSTest
    Dim TestSetTestsList, TestSetsList ' As List
    Dim tsTreeMgr 'As TestSetTreeManager
    Dim tSetFolder 'As TestSetFolder
    Dim i%

    Set TestSetFact = QCConnection.TestSetFactory
    Set tsTreeMgr = QCConnection.TestSetTreeManager

    Set tSetFolder = tsTreeMgr.NodeByPath("Root\folder of test set")

    Set TestSetsList = tSetFolder.FindTestSets("test case name")
    Set theTestSet = TestSetsList.Item(1)
     With theTestSet                                                  --- here i am receiving the error" 
        Debug.Print "Test Set ID = " & .ID & ", Name = " _
            & .Name & ", TestSetFolder = " & .TestSetFolder

     Set TSTestFact = theTestSet.TSTestFactory
    Set TestSetTestsList = TSTestFact.NewList("")
    
        Dim sID$
    For Each theTSTest In TestSetTestsList
        i = i + 1: If i > 10 Then Exit For
        With theTSTest
            Debug.Print "TSTest Name: " & .Name, "ID: " & .ID, _
                "TestID: " & .testID, "Instance: " & .instance
            sID = theTSTest.ID 'Save the last ID
        End With
    Next theTSTest

    Debug.Print "Last TSTestID = " & sID

 

    Set theTSTest = TSTestFact.Item(sID)
    With theTSTest
    Debug.Print "TSTest by ID Name: " & .Name, "ID: " & .ID, _
        "TestID: " & .testID, "Instance: " & .instance
    End With


End Sub

Frequent Advisor
Tomi_Assure
Posts: 35
Registered: ‎04-30-2010
Message 2 of 4 (212 Views)

Re: Getting error while running below code in excel macros

Are you sure the Test Set is found? You have no check in place that theTestSet is an actual Test Set. The Test Set is not found the With block cannot work.

Occasional Advisor
panki
Posts: 12
Registered: ‎01-07-2014
Message 3 of 4 (200 Views)

Re: Getting error while running below code in excel macros

how can i check that?

 

I am new in the vba coding dont have much knowledge. please suggest

Occasional Advisor
panki
Posts: 12
Registered: ‎01-07-2014
Message 4 of 4 (175 Views)

Re: Getting error while running below code in excel macros

It is solved now... thanks alot.

The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.