sancarn / stdVBA

VBA Standard Library - A Collection of libraries to form a common standard layer for modern VBA applications.
MIT License
288 stars 60 forks source link

How to install - Compile errors #66

Closed RealFoxie closed 10 months ago

RealFoxie commented 1 year ago

I added all the files under /src to test out the functionality, but unfortunately when pressing "compile VBAproject" (or trying to run code) I get various compile errors about user defined variables (like IUnknown) in the library files. I opened the fullbuild.xlsm and there the files can compile without the same problem. Should I extract the classes out of fullbuild.xlsm and import those, or what is the way to "install" these classes to use in other projects, of copying the files under /src doesn't work?

I am using excel2013 32-bit

sancarn commented 1 year ago

Interesting that it's complaining about IUnknown, I do vaguely remember that myself. These types are hidden:

  1. Open Object Browser
  2. Right click in the Left/Right pane and click "Show Hidden Members"

Typically speaking if you want to use a file, you drag and drop it into your VBA project explorer. Additionally you wouldn't usually import all modules, only the ones you require for a particular task.

Installation is something I definitely have to document better, so thanks for raising the issue 👍

RealFoxie commented 1 year ago

Even a sentence that installing is just copying the necessary modules from src would be a good addition. If only to know that if something doesn't work, it isn't the "installing" that is the problem :)

When trying to compile I get "user-defined type is not defined" for IAccessible for Private proxyParent As IAccessible in stdAcc (line 226). I looked at object browser and only find IAccessible_Methods class (+ CreateFromIAccessible and IAccessibleFromHwnd because of matching string). For IUnknown it finds EIUnknown class and the member IUnknown under EKnownInterfaces. I'm not entirely sure what the problem could be, as I'm not familiar with the low level programming of VBA. I do have a very limited amount of references active (Visual basic for Applications, Microsoft Excel 15.0 Object Library and Microsoft Forms 2.0 Object Library). Maybe the problem lies there?

If you have any guidance what I could try out, I'm happy to check. But unfortunately I don't really know what else to check. I'm used to more modern software 😅

sancarn commented 1 year ago

When trying to compile I get "user-defined type is not defined" for IAccessible for Private proxyParent As IAccessible in stdAcc (line 226).

Apologees for the late response, as discussed in above post you need to show hidden members. Did you try this yet?

image

Alternatively could you check if stdole2 library is referenced? (This is usually referenced by default... Not sure why it would have been removed?) image

RealFoxie commented 1 year ago

Yes, both OLE Automation and Microsoft Office Object Library was needed to make it work. I disabled some of them because in the past they gave some weird errors on very old laptops and at the time my code didn't need those references. I also did the show hidden members (apperently last time I missclicked, which is why they didn't show up) and IUknown is now seen. It also does not bug on these special types anymore.

The next compile error I get is for vtype (in stdCallback) as "by ref argument mismatch". It also shows Enum LongPtr in red (I'm not sure what this means though). But at least the reference errors are already gone.

When I have more time I'll try to import just the modules I need and see if those work and maybe am able to track down the problem more clearly.

Thanks for the help :)

sancarn commented 1 year ago

The next compile error I get is for vtype (in stdCallback) as "by ref argument mismatch". It also shows Enum LongPtr in red (I'm not sure what this means though). But at least the reference errors are already gone.

Ah! 32-bit VBA7, yeah... I did actually fix that issue on my other PC but looks like I forgot to push the changes to the main repo. Thanks for the reminder :) Will try to get that fixed soon 👍 Difficult catering for many different versions of Office...

Don't worry about Enum LongPtr in red, that's pretty usual in VBA7 and shouldn't cause any issues.

sancarn commented 1 year ago

stdCallback errors should be fixed now :)