Results 1 to 4 of 4

Thread: Reference Office 15.0 Missing, Only Office 16.0 Object Library Available

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2023
    Posts
    2

    Reference Office 15.0 Missing, Only Office 16.0 Object Library Available

    Hi All,

    been using the Office 16.0 Object Library for a while now, without any issues, until these last days.
    I'm creating an Excel chart through interop, and :

    this works:
    ser1.MarkerBackgroundColor = RGB(14, 43, 120)
    ser1.MarkerForegroundColor = rgb(14, 43, 120)

    but this doesn't:
    ser1.Format.Line.ForeColor.RGB = RGB(4, 42, 110)

    After Forecolor, VS suggests RGB, all good, but it immediately underlines it in red and gives the following error:
    Error BC30652 Reference required to assembly 'office, Version=15.0.0.0, containing the type '_IMsoDispObj'. Add one to your project

    I only have version 16.0.0.0 available as reference, not version 15.0.0.0.
    Maybe .Format.Line.ForeColor.RGB is an office 15.0 thing and not office 16.0? but then, there must be a way to change forecolor of a line in a chart in office 16, it can't be impossible, right?

    Any ideas on how to proceed? much appreciated!

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,989

    Re: Reference Office 15.0 Missing, Only Office 16.0 Object Library Available

    It's fairly rare for the interop to change, but it does happen. When there are changes, they do tend to be in less visited areas of the interop, and this appears to be one.

    In general, I recommend switching to late binding, but that likely won't help in this case, or at least won't totally solve the problem. Late binding allows you to not care about which version of the interop you have. In fact, you'd remove the reference entirely. However, it is also assuming that at least SOME version of the interop is there (which you do have, of course) and that it hasn't changed in any way regarding the methods you are calling (which is not a condition you are currently meeting). You switch to late binding by removing the reference. Of course, that will cause all kinds of missing type problems at compile time, so you change all those types to Object. You also have to set Option Strict OFF for the code page (you shouldn't do that for the whole project, but just for the page).

    By switching to late binding, the program will use whatever version of the interop is available. In this case, though, since you already know that the version of the interop you are using doesn't have the functionality, all this would do would be to shift the error from compile time when it is relatively easy to identify, to run time when it will be much harder to identify. So, while it's a good general solution, it won't help you any.


    I haven't worked with exactly that, but I'm not sure that ForeColor is right for a line. After all, when it comes to a line, what is fore and what is back? Is there just a Color property?
    My usual boring signature: Nothing

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2023
    Posts
    2

    Re: Reference Office 15.0 Missing, Only Office 16.0 Object Library Available

    Quote Originally Posted by Shaggy Hiker View Post
    It's fairly rare for the interop to change, but it does happen. When there are changes, they do tend to be in less visited areas of the interop, and this appears to be one.

    In general, I recommend switching to late binding, but that likely won't help in this case, or at least won't totally solve the problem. Late binding allows you to not care about which version of the interop you have. In fact, you'd remove the reference entirely. However, it is also assuming that at least SOME version of the interop is there (which you do have, of course) and that it hasn't changed in any way regarding the methods you are calling (which is not a condition you are currently meeting). You switch to late binding by removing the reference. Of course, that will cause all kinds of missing type problems at compile time, so you change all those types to Object. You also have to set Option Strict OFF for the code page (you shouldn't do that for the whole project, but just for the page).

    By switching to late binding, the program will use whatever version of the interop is available. In this case, though, since you already know that the version of the interop you are using doesn't have the functionality, all this would do would be to shift the error from compile time when it is relatively easy to identify, to run time when it will be much harder to identify. So, while it's a good general solution, it won't help you any.


    I haven't worked with exactly that, but I'm not sure that ForeColor is right for a line. After all, when it comes to a line, what is fore and what is back? Is there just a Color property?
    Hi Shaggy,

    thank you for you reply.
    I was similarly confused with "Fore" and "Back" color for a line, however, those are the 2 references that pop up on VS. I did check on VBA and it uses Forecolor too (I just recorded a Macro and read the script), and everything I found online (though not abundant) refered to Forecolor too.

    Anyway... I'm triping. I open the code again to try late biding, and to my surprise, without changing anything of the original code, it now compiles, gives no errors, and works fine. No need for late binding, maybe my computer just needed some rest.

    thanks again!

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,989

    Re: Reference Office 15.0 Missing, Only Office 16.0 Object Library Available

    I've seen that happen. It's very annoying. If a problem is going to be a problem, it should have the decency to stick around to be solved.
    My usual boring signature: Nothing

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