Results 1 to 5 of 5

Thread: late binding error

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2010
    Posts
    132

    Question late binding error

    i turned Option Strict On

    and i get an error on all the ".Cells" lines saying option strict on disallows late binding.
    Code:
                    a = 1
                    b = 3
                    c = 2
                    d = 1
                    With oSheet
                        Do Until a > 7
                            Do Until .Cells(b, a).Value = ""
                                .Cells(b, a).activate()
                                If .Cells(b, a).Value = .Range("IV" & d).Value Then
                                    .Cells(b, c).Value = .Cells(b, c).Value + 1
                                    d = d + 1
                                Else
                                    If .Range("IV" & d).Value = "" And d < 20 Then
                                        d = d + 1
                                        b = b - 1
                                    End If
                                End If
                                b = b + 1
                            Loop
                            a = a + 2
                            b = 3
                            c = c + 2
                            d = 1
                        Loop
                    End With

  2. #2
    Frenzied Member
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,158

    Re: late binding error

    option strict on disallows late binding.
    That's the answer, If you want to use Late Binding in .net then you have to let the option strict off

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2010
    Posts
    132

    Question Re: late binding error

    oh.. heh.. right, i as told that having that Off is bad ans i should have it On .... can someone give me an example of my code if it wasnt late binding?

  4. #4
    Frenzied Member
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,158

    Re: late binding error

    you can follow the second link in my signature.

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: late binding error

    If it's not late binding, then it's early binding... and the code itself would be exactly the same. The difference comes in on how & what the variables get dimmed as and how they are created. And if there's a reference or not.

    Yes, normally Option Strict On is a good thing... the exception is when it comes to office products. The problem with early binding there is if you reference a particular version of Office... you're locked into that version. No other version will work.

    Best way to deal with it is to set a reference for development and use early binding - this will give you intellisense. do your best to keep the code isolated in its own module or class. Once done, turn off Option Strict FOR THAT FILE ONLY... but putting Option Strict Off at the top of just that code file. The remove the reference, and change the types so that they are objects... and you should be set for late binding, which will allow it to run against almost any version of office.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

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