Access Application.Run "Can't Find The Procedure" only on another workstation - Printable Version +- 0Day Forums (https://0day.red) +-- Forum: Coding (https://0day.red/Forum-Coding) +--- Forum: JScript (https://0day.red/Forum-JScript) +--- Thread: Access Application.Run "Can't Find The Procedure" only on another workstation (/Thread-Access-Application-Run-quot-Can-39-t-Find-The-Procedure-quot-only-on-another-workstation) |
Access Application.Run "Can't Find The Procedure" only on another workstation - aurists573194 - 07-24-2023 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(); RE: Access Application.Run "Can't Find The Procedure" only on another workstation - pettiness871557 - 07-24-2023 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`. |