Results 1 to 5 of 5

Thread: run-time error 424 (Object required)

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2013
    Posts
    35

    Question run-time error 424 (Object required)

    Hello

    The 424 error occurs when an object is necessary.
    I’m having trouble to reference an instruction to a property of an object.
    The object in question was created in a form and the instruction that needs it belongs to a class of functions.
    I tried starting and restarting and create a new object in the function, but I got the error 91 (Object variable or with block variable not set).

    Question: How do I refer the instruction to the object property already created?
    Data: 1 -The instruction belongs to Excel.Application.
    2- I’m using VB6

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: run-time error 424 (Object required)

    not enough information

    The object in question was created in a form
    is this form in excel or VB6?
    show some of your code to indicate where the problem is occurring
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3
    Member
    Join Date
    Mar 2012
    Posts
    34

    Re: run-time error 424 (Object required)

    If I understand you correctly. The object was defined within a form and a class module needs to reference some property within the object.
    If that is correct regardless if you are in Office VBA or VB you will have to create a variable or property within the class that is of the same type as
    the object in the form. You would add a subroutine to the class module that has as an argument to the subroutine an object of the same type as
    the object on the form. Within the subroutine set the property within the class equal to the argument supplied to the subroutine.
    Within the class you can now refer to the property and it's properties from within the class.

  4. #4

    Thread Starter
    Member
    Join Date
    Feb 2013
    Posts
    35

    Re: run-time error 424 (Object required)

    I think this may clarify a little better

    ***********************************
    Public Function OpenExcel()
    Dim xl As Object

    Set xl = CreateObject("Excel.Application")
    xl.Workbooks.Open ("C:\\excelformat.xls")
    xl.Visible = True
    Set xl = Nothing

    End Function
    ***********************************
    ***********************************
    Public Function NewPag()
    Dim xl As Object

    Set xl = CreateObject("Excel.Application")
    Line = ActiveCell.Row
    Column = ActiveCell.Column
    Sheets("Plan3").Select
    Range("A1:I48").Select
    xl.Selection.Copy
    Sheets("Plan2").Select
    Range("A" & Line + 3).Select
    ActiveSheet.Paste
    Range(Column & ":" & Line + 5).Select
    Set xl = Nothing

    End Function
    ***********************************
    __________________________________________________________
    |Run-time error 91 (Object variable or with block variable not set).|
    __________________________________________________________

  5. #5
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: run-time error 424 (Object required)

    Run-time error 91 (Object variable or with block variable not set).|
    which line?
    i guess activecell
    sheets
    range

    all objects not set unless your code is written within excel
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width