"Unspecified Error" 80004005 创建新的 Access 数据库时,仅在另一台工作站上
"Unspecified Error" 80004005 when creating new Access database, only on another workstation
我有一个由 cscript
调用的 JScript 文件,这个脚本是一个概念验证,它创建一个新的 Access 2007 格式数据库,导入一组 VBA模块导入数据库,然后从导入的模块运行子例程。
这个脚本在我自己的电脑上运行完美。我安装了 Office 2013。但是,我将此脚本带到同事的机器上,让他尝试 运行。在他的机器上,我们收到类似 createdb.js (22, 1): Unspecified error
的错误,错误代码为 80004005。我的代码如下:
'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
s 但没有成功。这可能是什么问题?
由于您没有使用任何可选参数,因此请将其关闭:
access.NewCurrentDatabase(basePath + '\ImportTest.accdb', acNewDatabaseFormat.Access12);
如果参数列表中还有您要稍后使用的其他参数,则只需为可选参数指定一个值。
我有一个由 cscript
调用的 JScript 文件,这个脚本是一个概念验证,它创建一个新的 Access 2007 格式数据库,导入一组 VBA模块导入数据库,然后从导入的模块运行子例程。
这个脚本在我自己的电脑上运行完美。我安装了 Office 2013。但是,我将此脚本带到同事的机器上,让他尝试 运行。在他的机器上,我们收到类似 createdb.js (22, 1): Unspecified error
的错误,错误代码为 80004005。我的代码如下:
'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
s 但没有成功。这可能是什么问题?
由于您没有使用任何可选参数,因此请将其关闭:
access.NewCurrentDatabase(basePath + '\ImportTest.accdb', acNewDatabaseFormat.Access12);
如果参数列表中还有您要稍后使用的其他参数,则只需为可选参数指定一个值。