0

I have a lot of access files that have Code Behind event procedures defined using VBA. I want to search this code for a large number of strings.

I can accomplish this by selecting the Access Class object in Microsoft Visual Basic for Applications, right clicking and selecting "Export File..." then running findstr, but I can only export one class object at a time (it takes a very long time).

Is there a way to export multiple Access Class Objects at once, or script it?

0

So, I made an application that exports all the form definitions for an access file. This includes the code behind, so with the following code and a script to pull only the CodeBehind section, you can get a workable solution.

using Microsoft.Office.Interop.Access;
using System;

namespace AccessExporter
{
    class Program
    {
        static void Main(string[] args)
        {
            ApplicationClass app = new ApplicationClass();

            String fileName = @"C:\AccessFile.accdb";
            app.Visible = false;
            app.OpenCurrentDatabase(fileName);

            foreach (AccessObject obj in app.CurrentProject.AllForms)
            {
                Console.WriteLine(obj.Name);
                app.SaveAsText(AcObjectType.acForm, obj.Name, String.Format(@"C:\{0}.txt", obj.Name));
            }

            app.CloseCurrentDatabase();
        }
    }
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.