Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 857 Vote(s) - 3.56 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Access Application.Run "Can't Find The Procedure" only on another workstation

#1
Coming in off my last question (

[To see links please register here]

)...

Again, I have Office 2013 installed, my coworker has Access 2007. My script below creates a new Access database through automation, imports a series of VBA modules from text, then runs a sub found in one of the imported modules. The script runs fine on my machine, but on my coworker's machine it says `Microsoft Office Access can't find the procedure 'ImportAllSource.'` We've also tried prefixing the name of the procedure with the name of the module it lives in (`"VCS_ImportExport.ImportAllSource"`), and the name of the project as it appears in the VBE environment (`"ImportTest.ImportAllSource"`), but with no luck and the same error.

Revised script:

'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);
db = access.CurrentDb();
prop = db.CreateProperty('AppTitle', dbText, 'IG IMI Database');
db.Properties.Append(prop);
prop = db.CreateProperty('StartUpForm', dbText, 'Main Switchboard');
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();
Reply

#2
Had an epiphany. The problem was some code in the loaded modules - namely, a couple `Declare` statements using the `PtrSafe` keyword. It's valid syntax in Access 2013, but not in 2007.

So, if there's an error with the VBA code in a loaded module, Access will play dumb when you try to invoke `Application.Run`.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through