By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,193 Members | 1,812 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,193 IT Pros & Developers. It's quick & easy.

Application Automation : Running Embedded Code

Expert Mod 15k+
P: 31,761
Actually, the question's a little more involved than that. Let me try to explain as succinctly as I can.

I want to know how to execute code that is held within the project I'm trying to open using Application Automation.

To give an example to illustrate the concept :
I have in most of my Excel files a public function (ToA1()) that converts Rows and Columns from simple numbers to A1 notation. When I open one of these files from an Access database project, I would like to call this function from within my Access code (the part where it's working within the spreadsheet), but that is proving difficult (to say the least).

After doing some googling, I found the Application.Run() function, which allows me to execute macros (I'm guessing just subroutines), but I need it to return the value to me if possible. One negative side-effect of this for me is that ALL parameters must be passed positionally. I'm a heavy user of named arguments in my code, for reasons of clarity.

The only alternative I can see is to duplicate all my Excel routines into a separate module in my database. Not the end of the world, but not ideal either. Maintenance would be an issue, trying to avoid code getting out of synch.
Aug 14 '08 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 15k+
P: 31,761
Having completed a little more testing and experimenting (and having re-read the help section on Application.Run()), I now find that I CAN, in fact, refer to functions in this way too. The parameters are still not named but I have successfully returned the required string from my ToA1() function.

I find this an acceptable solution in the circumstances (No repeating of my Excel code inside Access databases required), but nevertheless, if anyone has any tips on accessing the code directly (without the requirement to use Application.Run()) I'd be very pleased to hear of it. I'm not sure at this stage that this is even supported, but any updates gratefully received.
Aug 14 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.