Our current macros retrieve data from a Microsoft SQL database. To do
this I created an activeX object that was between our database and the
data enabled templates.
I know that .Net has great database support but once I execute a
stored procedure and have the data in a object created with managed
code, is there any way for our templates to access the data without
themselves being rewritten in .Net? I.E. We want to access the data
via macros written in VBA.
Thanks.
I'm not really sure how you're envisioning this, but taken literally:
No, there's no way your VBA can use a .NET dataset. You'd need to
convert that data to something Office can work with. This could be an
array, a delimited string or a XML (as a string) if you don't want to
write the data to a file and have the VBA pick up the file.
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org
This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :-)
Thanks Cindy.
I would rather not write a file and pick it up from VBA if I can avoid
it. If my VB.NET code puts the data into a string how do I make that
string accessible from VBA? Can I pass an array from VB.Net code to
VBA code? Can you show me a code snippit that does this?
Thanks again.
> I would rather not write a file and pick it up from VBA if I can avoid
> it. If my VB.NET code puts the data into a string how do I make that
> string accessible from VBA? Can I pass an array from VB.Net code to
> VBA code? Can you show me a code snippit that does this?
>
I don't have time just now to work out an example that meets your exact
scenario. But see if this article in the MSDN documentation gets you
started?
http://msdn.microsoft.com/en-us/library/bb608621.aspx
It should show you how to create a function in your VSTO app that can be
called by VBA and return a value (a string, for example).
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
Thanks Cindy. That's perfect.