“Unspecified Error” 80004005 when creating new Access database, only on another workstation

假装没事ソ 提交于 2019-12-12 04:38:33

问题


What I have is a JScript file that gets called by cscript, and this script is a proof-of-concept that creates a new Access 2007 format database, imports a set of VBA modules into the database, and then runs a subroutine from the imported modules.

This script works flawlessly on my own computer. I have Office 2013 installed. However, I brought this script over to a coworker's machine and had him attempt running it. On his machine, we get an error that looked something like, createdb.js (22, 1): Unspecified error and the error code is 80004005. My code, below:

'use strict';

/**
 * AcNewDatabaseFormat Enumeration
 * Used with the NewCurrentDatabase method to specify the database format of the newly created database.
 */
var acModule = 5,
    dbText = 10,
    acNewDatabaseFormat = {
        UserDefault: 0,
        Access2000: 9,
        Access2002: 10,
        Access12: 12
    };

var fs = new ActiveXObject('Scripting.FileSystemObject');
var access = new ActiveXObject('Access.Application');
var basePath = fs.GetParentFolderName(WScript.ScriptFullName);
var db, prop, vcsFolder, fCur, module;

//Create DB and set up some superficial things.
access.NewCurrentDatabase(basePath + '\\ImportTest.accdb', acNewDatabaseFormat.Access12, null, "", "");
//access.OpenCurrentDatabase(basePath + '\\ImportTest.accdb');
db = access.CurrentDb();
prop = db.CreateProperty('AppTitle', dbText, 'My New Database');
db.Properties.Append(prop);
prop = db.CreateProperty('StartUpForm', dbText, 'Main Form');
db.Properties.Append(prop);
db.Properties('UseMDIMode') = 1;

//Add MSAccess-VCS modules
vcsFolder = fs.GetFolder(basePath + '\\MSAccess-VCS');
fCur = new Enumerator(vcsFolder.files);
for (; !fCur.atEnd(); fCur.moveNext()) {
    module = fCur.item().Name.replace('.bas', '');
    access.LoadFromText(acModule, module, fCur.item());
}

access.Run('ImportAllSource');
access.Quit();

Line 22, character 1 is access.NewCurrentDatabase(basePath + '\\ImportTest.accdb', acNewDatabaseFormat.Access12, null, "", "");. Office (and Access!) 2007 is installed on his machine. We tried other AcNewDatabaseFormats with no luck. What could possibly be the issue here?


回答1:


Since you're not using any of the optional parameters, just leave them off:

access.NewCurrentDatabase(basePath + '\\ImportTest.accdb', acNewDatabaseFormat.Access12);

You only need to specify a value for optional parameters if there are other parameters you want to use later in the argument list.



来源:https://stackoverflow.com/questions/30821983/unspecified-error-80004005-when-creating-new-access-database-only-on-another

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!