469,159 Members | 1,392 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,159 developers. It's quick & easy.

Application Automation : Running Embedded Code

NeoPa
32,167 Expert Mod 16PB
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
1 1552
NeoPa
32,167 Expert Mod 16PB
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.

Similar topics

3 posts views Thread by Pelle | last post: by
2 posts views Thread by KC | last post: by
5 posts views Thread by Geoff Jones | last post: by
3 posts views Thread by Daniel Clark | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.