What is the missing library? - ms-access

On Access VBA, I get an error on Environ in this string:
path = Environ("Temp") & "\DOTS\"
The error I get is the following:
How can I know what is the missing library?

Visual Basic Editor, select Tools --> References.
See if there are references whose check box is ticked (they are listed at the top) that start with MISSING: . If so, look further down the list for the version compatible with your application (e.g. if is says MISSING: Microsoft Word 15.0 Object Library look for a lower # in your references list like Microsoft Word 14.0 Object Library)

Related

ActCtx + manifest + comhost + .NET 6.0: does it work, does anyone has a working example?

My goal is to expose a .NET 6.0 library to COM, in order to use it from VBA in MS Access. And to use the manifest approach rather than using the registry.
Got article "Exposing .NET Core components to COM" working, using their "COM server sample" example code.
This example however requires that a manifest file is present in the folder containing the executable. When using the COM object from MS Access we do not want to place the manifest file and other files in the MS installation folders.
The suggested solution is to create an Microsoft.Windows.ActCtx object and let that object create my COM object, using the Manifest property of the ActCtx object to specify the manifest file.
This is the part that continues to fail. actCtx.CreateObject("") gives an Invalid Cast exception, even without assignment of the result to a variable, hence it is an internal issue. No additional details, no information in the event log. Tried this in C# and from VBA.
I have a few questions:
Is ActCtx the way to specify the manifest path, or is there a better way to do this from VBA in MS Office?
The example uses a COM host, which seems to be some COM class / object factory, which in turn helps creating my COM object. As opposed to .NET Framework this COM host seems to be introduced for .NET Core; .NET 6.0 in my case. Is the COM host required? Is the simpler direct instantiation possible?
Does anyone has answers to these questions, tips, or even better: a working example?
Some progress but I am still not happy. Abandoned the ActCtx approach for a while and tried to create the COM server object of the sample directly in MS Access VBA. Added a reference to the com host, say COMServer.comhost.dll, as opposed to the implementation COMServer.dll. Created the object, simply with New. Error: class not registered. Performed a regsvr32 COMServer.comhost.dll and the sample works.
Although the sample works there are now again registry entries: the guid of the server class has been added to the registry. Regfree COM not achieved.
This is despite COMServer.comhost.dll looking promising. A tlb type library built separately and embedded in the .dll is seen by VBA: intellisense works and the object browser works. The manifest seems to be correctly embedded in the .dll too, and takes precedence over the manifest on disk.
The question remains how to avoid the regsvr32 step and make the solution working by just adding the reference to COMServer.comhost.dll, in MS Access VBA.

ms access compile error: user-defined type not defined

i am trying to add this to my code :
Dim myRS1 As DAO.Recordset
yet it gives me this error:
Compile error: user-defined type not defined
I have gone through these links:
compile error: user-defined type not defined
Compiler Error: User-defined types not defined
What is "Compile error User-defined type not defined"?
w7 -> VB6 error "User-defined type not defined"
http://www.tek-tips.com/viewthread.cfm?qid=1731794
Yet to no avail.
I have tried adding the Microsoft Access 3.6 library yet then it says Error in loading DLL
I don't understand, my previous projects use the exact same code yet they work completely fine.
I guess we are taking about Access 2003 here.
In the Visual Basic windows, menu 'Tools > References' having ticked & selected 'Microsoft DAO 3.6 Object Library', it should show the location of the DLL at the bottom of the form. It will be something like:
C:\Program Files\Common Files\Microsoft Shared\DAO\DAO360.DLL
Check that DLL, and associated files exist. Compare the folders contents with another working PC, and copy across files as necessary. (Always take backup of original state.) The error 'Error in loading DLL' may indicate a corrupted DLL.
Also check the 'Object Browser', in the Visual Basic windows, menu 'View > Object Browser'. You should able to select the 'DAO' library in the Top Combo, and then browse it's Classes & Members.

How to programmatically convert Access 1997 .mdb to Access 2007 .accdb

I'm in the starting process of building an application that walks through a folder structure, starting at a given root path, and converts all found Access 1997 .mdb files into the newer Access 2007/2010 .accdb format. However, I'm running into some troubles when doing to actual file conversion.
I'm using Microsoft's Access Interop API (https://msdn.microsoft.com/en-us/library/office/ff193465.aspx) to handle the conversion, so this has to be written in VBScript. Script is below:
Dim app
Set app = CreateObject("Access.Application")
app.ConvertAccessProject "C:\Users\[User]\Access Conversion Utility\sample.mdb", "C:\Users\[User]\Access Conversion Utility\converted.accdb", acFileFormatAccess12
When run, I get the error "The project cannot be converted into this format. The project can only be converted to Access 2000 or newer format." Yet, this same error message shows up regardless of the file parameter enum value, be it 'acFileFormatAccess97' or 'acFileFormatAccess2000'. Does anyone know the details of this error and what a possible solution could be? I've tried changing the extension of the second parameter, thinking that was part of the issue, but this made no changes to the error message.
The sample file I'm using is able to be opened in Access just fine, it's just the conversion itself that fails.
By all means, if anyone has a better idea or approach to do the conversion programatically, I would love to hear it, but this is the only one I was able to find. The plan is to run this script from a GUI application written in C#, but also allow for the application to be run via the command line as well.
I'm using Microsoft's Access Interop API ... so this has to be written in VBScript.
Nonsense. I just tried this in C# (Visual Studio 2010) and it worked fine for me with Access 2010:
// COM reference required for project
// Microsoft Access 14.0 Object Library
var app = new Microsoft.Office.Interop.Access.Application();
app.ConvertAccessProject(
#"C:\Users\Public\test\a97test.mdb",
#"C:\Users\Public\test\a2007converted.accdb",
Microsoft.Office.Interop.Access.AcFileFormat.acFileFormatAccess2007);
app.Quit();
Note that this will almost certainly not work with Access 2013 and later, but neither would a VBScript implementation of COM Interop for those versions of Access since they absolutely refuse to open Access_97 (and earlier) databases.
Problem is twofold.
First, Access 2007 and later won't read older formats than the JET 4 format of Access 2000.
Second, the constant for the 2007 format is acFileFormatAccess2007, not acFileFormatAccess12, it's the numeric value of the constant that is 12.
On this point, the documentation is wrong:
AcFileFormat Enumeration (Access)
So you will have to obtain an older version of Access for the first conversion to JET 4, then another step to convert to 2007 format.
Edit:
Or, of course, do as Gord shows.
Plain VBScript does not know about the ac* constants. So define them properly.

Access COMDLG32.dll Reference Gone

To make a specific application work on another user's machine, we removed a reference for Microsoft Common Dialog Control 6.0 (SP3), or "COMDLG32.dll", from the application. We thought this would be appropriate because the application appeared to compile just fine without it.
Unfortunately, this was a trick. The reference appears to be required for different control boxes used throughout the app. Now that it's been removed, I can't seem to locate it in the References selection box in Access's VBA editor.
It used to be referenced by name (Microsoft Common Dialog Control 6.0) in the list of Available References to add to the application. Now, I'm only able to find the reference if I browse to the list of common references. "COMDLG32.dll" is an option. However, if I select the file, I'm told that I'm unable to use the reference.
Help?

Import MS Word Form Field to Access - Missing Reference?

I am trying to import data into access 2007 from a MS Word form field.
I have followed the tutorial here: http://msdn.microsoft.com/en-us/library/aa155434(v=office.10).aspx
When I run the VBA code I get a compile error that says "User-defined type not defined". After doing some research I've found that it is likely because I am missing a reference to an object in an object library.
I have the following object libraries referenced:
Visual Basic For Applications
Microsoft Access 12.0 Object Library
Ole Automation
Microsoft Office 12.0 database engine Object library
Microsoft Word 12.0 Object library
The error is thrown when the sub is called here:
Sub GetWordData()
Am I missing a reference, or do I have another problem?
Thanks in advance
Ensure that you have set a reference to the Microsoft ActiveX Data Objects x.x Library.
In the code window, choose Tools->References, scroll to the library and tick it.
Note that using library references, rather than late binding (Create.Object("Word.Application")), makes it easier to access properties and methods but can mean that your code will not run in other environments.