Roger's Access Library Homepage
Forum Home Forum Home > Other Download Libraries > MS Access MVP Libraries > Tejpal, A.D.
  New Posts New Posts RSS Feed - ModulesAddIn_BulkImportExport
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Please consider donating $1 per sample downloaded, (find out why here)


 Post Reply Post Reply
A.D. Tejpal View Drop Down
Microsoft MVP
Microsoft MVP

Joined: 30 Jun 2008
Status: Offline
Points: 192
Post Options Post Options   Thanks (0) Thanks(0)   Quote A.D. Tejpal Quote  Post ReplyReply Direct Link To This Post Topic: ModulesAddIn_BulkImportExport
    Posted: 14 Oct 2008 at 3:23am

Explanatory Notes

    This utility enables bulk import of .bas, .cls or .txt files as general or class modules, or export of existing modules to destination folder as .bas / .cls files.

    Microsoft Access 2000 or later
    Microsoft Windows 98 or later

    DAO 3.6
    Microsoft Scripting RunTime
    Visual Basic for Applications Extensibility 5.3

    Note: It is not necessary for the host db to have the above references.

    The folder ModulesAddIn_BulkImportExport should be put directly on the C: drive, so that the path for .mda file is -
C:\ModulesAddIn_BulkImportExport\ModulesAddIn_BulkImportExport.mda. (This is important, so as to establish the correct registry key)

    Open any database in Access and click on Tools > Add-Ins > Add-In Manager.
    Click on Add New. Browse to the folder and file at   
    Click OK. This will copy the .mda file to Microsoft's default Add-in folder for Access.
    You have to do this only once.

    To use ModulesAddIn_BulkImportExport from within any database, click Tools > Add-Ins > ModulesAddIn_BulkImportExport

    Imp: Before invoking the AddIn, it should be ensured that the host db is free of any compile error.

Technical Notes:

    Add-In named ModulesAddIn_BulkImportExport, when invoked in the host db, displays a list box at right showing existing modules. On clicking the command button captioned "Get Folder", the user can browse to the folder containing .bas, .cls or .txt files required to be imported as modules. As soon as the folder is selected, the list box at left displays the names of files contained in this folder, along with type of module and line count.

    Selection of one or more files in the list box, followed by clicking of button captioned "Import", imports the selected files as new modules. Sorting is devised in such a manner that freshly imported modules get displayed prior to those already existing.

    Similarly existing modules as selected in the list box at right, can be exported as .bas / .cls files to destination folder. This folder, named ExportedModules, gets created in the same directory where the host db is located.

    Certain interesting factors pertaining to Add-Ins in general, are mentioned below: 

    1 - For code contained in modules belonging to the Add-In:
        (a) If the AddIn is opened independently, CurrentProject / CurrentDb are identical to CodeProject / CodeDb respectively (all refer to AddIn itself).
        (b) If the AddIn is activated in host db, CurrentProject / CurrentDb refer to host db while CodeProject / CodeDb refer to AddIn itself.
        (c) Host applications AllForms / AllReports / AllModules collections can be accessed by code in AddIn, using CurrentProject.
        (d) Tables / Queries are not covered by collections like those in prev para.
        (e) While the AddIn is in activated state, any query / table / form / report, whether in host db or in the AddIn, as well as modules in host db can be opened directly by name, using DoCmd statement in AddIn code, without having to use any special qualifier.
        (f) If any pair of similar objects exists both in the AddIn as well as the host db, code in AddIn module will act upon the object located in the AddIn itself.
        (g) For code in AddIn module, when the AddIn is in activated mode, queries / recordests based upon CurrentDb do not recognize the tables in AddIn itself, unless referred via IN clause, giving full path of the AddIN. This path, returned by CodeProject.FullName, refers to the original location of AddIn mda file e.g. C:\ModulesAddIn_BulkImportExport\ModulesAddIn_BulkImportExport.mda and not the shadow AddIn file in AddIns folder in MyDocuments. There is no such problem if queries / recordsets are based upon CodeDb instead of CurrentDb.
        (h) Modules belonging to the AddIn can not be opened by DoCmd mehod or otherwise addressed, even by code in the AddIn. DoCmd.CopyObject command can however be used for copying modules from AddIn to host db.
    2 - For code contained in modules belonging to the host db:
        (a) CurrentProject / CurrentDb are identical to CodeProject / CodeDb respectively, always referring to the host db, irrespective of the fact whether the AddIn is in activated state or not.
        (b) Whereas code in the AddIn can access all tables / queries / forms / reports, whether belonging to AddIn or the host db (see para 1 (e) above), code in host db can directly access only the objects belonging to host db itself. 
    Note:  General module named basCommDlg, an adaptation from Access Developer's Handbook, has been kindly provided by Bill Mosca


Back to Top
Sponsored Links

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.03
Copyright ©2001-2019 Web Wiz Ltd.