dcsimg
Results 1 to 7 of 7

Thread: Error running vba on office 2010, possibly late binding problem

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2013
    Posts
    911

    Error running vba on office 2010, possibly late binding problem

    Hi, im having a problem with a file that has been edited on office 2016 for an office 2010 user.

    initially the file was created on word 2010 and is a simple template which i think may have been downloaded as its format of objects in vba seemed to be irregular, anyway i went ahead and automated some simple data extraction from excel files that then changed the headers, some address information and added some tables at the end, i did have to change the file format though as it would not save in compatibility mode, not sure if that is also the problem.

    Everything works fine on my computer, but the client is having a problem with references, so what i did was try late binding which i have never actually done before, i think i have done it right but i am not really sure.

    i have just a couple of references to constants in both word and excel, and maybe a couple in office/vba itself which i have not added as its nothing that shouldnt be in all the office versions....... maybe im wrong there....

    i think i also tried removing all the references too on the project in my latest file, may also be a reason its failing.

    anyway, ill only post my original file without late binding since the other one just has 2 values i hardcoded and the references removed, the excel file is used to populate the word file, the word file contains the VBA not the excel file.

    when run you choose the excel file, it runs through and closes the original word file/template, and loads a new one with the data after you choose a save location.

    again this works fine on my office 2016 with both files (early and late binding)...i dont have office 2010 to test on.

    any ideas?
    thanks

    sample.zip

    VBA File.zip
    Yes!!!
    Working from home is so much better than working in an office...
    Nothing can beat the combined stress of getting your work done on time whilst
    1. one toddler keeps pressing your AVR's power button
    2. one baby keeps crying for milk
    3. one child keeps running in and out of the house screaming and shouting
    4. one wife keeps nagging you to stop playing on the pc and do some real work.. house chores
    5. working at 1 O'clock in the morning because nobody is awake at that time
    6. being grossly underpaid for all your hard work


  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    23,778

    Re: Error running vba on office 2010, possibly late binding problem

    vba is generally forward compatible, but not always backwards

    are you running in 32 or 64 bit office?
    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

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2013
    Posts
    911

    Re: Error running vba on office 2010, possibly late binding problem

    I am indeed running 64bit.........im guessing i need to change my variable types or install 32 bit, office has the mixed variable types right? i forgot
    Yes!!!
    Working from home is so much better than working in an office...
    Nothing can beat the combined stress of getting your work done on time whilst
    1. one toddler keeps pressing your AVR's power button
    2. one baby keeps crying for milk
    3. one child keeps running in and out of the house screaming and shouting
    4. one wife keeps nagging you to stop playing on the pc and do some real work.. house chores
    5. working at 1 O'clock in the morning because nobody is awake at that time
    6. being grossly underpaid for all your hard work


  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    23,778

    Re: Error running vba on office 2010, possibly late binding problem

    if you are only working with office objects mostly the code should be the same, any API calls etc not so, i have no version of 64 bit office to test on, only 2010 32 bit running on w10 64bit, mostly i use older versions of office

    i loaded your files into office 2010
    i have a missing reference for office to excel 16, i have not seen anything so far that should not run on 32 bit

    to convert to late binding, you need to
    remove the references to excel, word and possibly office
    change the 3 variables at the top of the module to type object
    all office constants need to have values assigned to them, either by using literal values or declaring them as constants
    there was a thread in vb6 forum recently, about the advantage of using a reference to the .tbl file, which is version independent, which would make all the constants available
    as the code is running in word, the word constants should be available anyway, but you should check any way, also check ms office contants, the only place i saw excel consatants was in the procedure findtables

    set XL = new excel.application
    should be changed to
    Code:
     set XL = createobject("excel.application")
    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

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2013
    Posts
    911

    Re: Error running vba on office 2010, possibly late binding problem

    I did find a couple of office references used with filedialog, so i updated those and that all looks good now.

    i did also find out the client has macros disabled so ummm not sure what to say there haha.

    there is another error on the clients machine that ive seen before and forgot how i fixed it, some/all references to the VBA objects are not recognised, specifically LCase() in the error message. i think last time i encountered this i just put 'VBA.' in front of everything im not sure.
    Yes!!!
    Working from home is so much better than working in an office...
    Nothing can beat the combined stress of getting your work done on time whilst
    1. one toddler keeps pressing your AVR's power button
    2. one baby keeps crying for milk
    3. one child keeps running in and out of the house screaming and shouting
    4. one wife keeps nagging you to stop playing on the pc and do some real work.. house chores
    5. working at 1 O'clock in the morning because nobody is awake at that time
    6. being grossly underpaid for all your hard work


  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2013
    Posts
    911

    Re: Error running vba on office 2010, possibly late binding problem

    ---sorry double posted-----
    Yes!!!
    Working from home is so much better than working in an office...
    Nothing can beat the combined stress of getting your work done on time whilst
    1. one toddler keeps pressing your AVR's power button
    2. one baby keeps crying for milk
    3. one child keeps running in and out of the house screaming and shouting
    4. one wife keeps nagging you to stop playing on the pc and do some real work.. house chores
    5. working at 1 O'clock in the morning because nobody is awake at that time
    6. being grossly underpaid for all your hard work


  7. #7
    PowerPoster
    Join Date
    Dec 2004
    Posts
    23,778

    Re: Error running vba on office 2010, possibly late binding problem

    there is another error on the clients machine
    this is almost always caused by a missing reference
    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
  •  



Featured


Click Here to Expand Forum to Full Width