Excel VBA Run Time Error '424' object required

后端 未结 4 723
不知归路
不知归路 2021-01-03 22:50

I am totally new in VBA and coding in general, am trying to get data from cells from the same workbook (get framework path ...) and then to start application (QTP) and run t

4条回答
  •  别那么骄傲
    2021-01-03 23:06

    The first code line, Option Explicit means (in simple terms) that all of your variables have to be explicitly declared by Dim statements. They can be any type, including object, integer, string, or even a variant.

    This line: Dim envFrmwrkPath As Range is declaring the variable envFrmwrkPath of type Range. This means that you can only set it to a range.

    This line: Set envFrmwrkPath = ActiveSheet.Range("D6").Value is attempting to set the Range type variable to a specific Value that is in cell D6. This could be a integer or a string for example (depends on what you have in that cell) but it's not a range.

    I'm assuming you want the value stored in a variable. Try something like this:

    Dim MyVariableName As Integer
    MyVariableName = ActiveSheet.Range("D6").Value
    

    This assumes you have a number (like 5) in cell D6. Now your variable will have the value.

    For simplicity sake of learning, you can remove or comment out the Option Explicit line and VBA will try to determine the type of variables at run time.


    Try this to get through this part of your code

    Dim envFrmwrkPath As String
    Dim ApplicationName As String
    Dim TestIterationName As String
    

提交回复
热议问题