“未指定的错误" 80004005创建新的Access数据库时,只能在另一个工作站上 [英] "Unspecified Error" 80004005 when creating new Access database, only on another workstation

查看:149
本文介绍了“未指定的错误" 80004005创建新的Access数据库时,只能在另一个工作站上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我所拥有的是一个被cscript调用的JScript文件,该脚本是一个概念验证,它创建了一个新的Access 2007格式数据库,将一组VBA模块导入数据库,然后运行导入的模块中的子例程.

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.

此脚本可在我自己的计算机上完美运行.我已安装Office 2013.但是,我将此脚本带到了同事的机器上,让他尝试运行它.在他的机器上,我们看到一个错误,看起来像是createdb.js (22, 1): Unspecified error,错误代码是80004005.我的代码如下:

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();

第22行,字符1为access.NewCurrentDatabase(basePath + '\\ImportTest.accdb', acNewDatabaseFormat.Access12, null, "", "");. Office(和Access!)2007已安装在他的计算机上.我们尝试了其他AcNewDatabaseFormat都没有运气.这里可能是什么问题?

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?

推荐答案

由于您未使用任何可选参数,因此请不要使用它们:

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.

这篇关于“未指定的错误" 80004005创建新的Access数据库时,只能在另一个工作站上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆