Error "User-defined type not defined" in VB in Access 2007

I get a compilation error in the following line of code:

Dim oXL As Excel.Application 

The code is in VB in MS Access 2007. The line above is the beginning of the segment for generating the MS Excel file. The obvious answer to me was to make sure that the "Microsoft Office 12.0 Object Library" was marked under "Tools"> "Links." I did this, but the error persists. Does Excel need to be installed side by side for this to work? What have I done wrong? Thanks in advance.

+4
source share
1 answer

You need to reference Microsoft Excel 12.0 Object Library or use late binding. Later, binding is almost always necessary if you are sharing your project with users who can have different versions of Excel installed.

For later binding you should:

 Dim oXL as object Set oXL = CreateObject("Excel.Application") 

Then your code should work as expected, without having to make a link ... unless you use any other special values ​​or Excel objects.

+13
source

All Articles