Solved

Call an MS Access Function/Sub and pass parameters from a C++ project

Posted on 2009-07-15
5
482 Views
Last Modified: 2013-12-14
I have NULL Experience with C++ and limited knowledge of VS2008.  I work with VBA and Access in particular.

I am working with Adobe Acrobat (for a very small plug in) and thus am forced to use C++.

My question is how can I call a MsAccess function or sub and pass it parameters?  At this stage I am looking for spoon feeding people so code examples or links to code examples would be great.
0
Comment
Question by:darbid73
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 31

Assisted Solution

by:Zoppo
Zoppo earned 100 total points
ID: 24862341
Hi darbid73,

I guess you think about starting and controlling MSAccess via OLE/Automation.

I think best is you read about this because it's a quite large field.

Here's a link to a Microsoft Knowledgebase article describing how to use Automation in MFC to get an interface to VBA procedures from MSAccess, I think you can find a lot of information there:

http://support.microsoft.com/?scid=kb%3Ben-us%3B266387&x=10&y=9 

It is written for some older version of MS VisualStudio, but the OLE-part IMO is quite up to date.

Further I suggest to google for 'MFC Msacc.olb', you'll find some samples about this ...

Hope that helps,

ZOPPO
0
 
LVL 20

Author Comment

by:darbid73
ID: 24862672
This could be a dumb statement question, but I cannot add MCF classes to these projects as they are not MFC projects.

Is there an alternative or do I have to make my project an MFC project?
0
 
LVL 20

Author Comment

by:darbid73
ID: 24862805
From what I can tell there are three ways to do this -

  1. With MFC, use the Visual C++ ClassWizard to generate "wrapper        classes" from the Microsoft Office type libraries. These classes, as       well as other MFC classes, such as COleVariant, COleSafeArray,       COleException, simplify the tasks of Automation. This method is       usually recommended over the others, and most of the Microsoft       Knowledge Base examples use MFC.
  2. #import, a new directive that became available with Visual C++ 5.0,       creates VC++ "smart pointers" from a specified type library. It is       very powerful, but often not recommended because of reference-       counting problems that typically occur when used with the Microsoft       Office applications.
  3. C/C++ Automation is much more difficult, but sometimes necessary to       avoid overhead with MFC, or problems with #import. Basically, you       work with such APIs as CoCreateInstance(), and COM interfaces       such as IDispatch and IUnknown.
0
 
LVL 20

Author Comment

by:darbid73
ID: 24866403
Zoppo - your post really got me into this as the problem as a beginner needing to just do one task in a subject he knows nothing about is what to search for.

I am now reading and the plug-in CANNOT implement OLE automation or be an ActiveX server through the use of MFC.  The plugin must use DDEML library to handle DDE messages.

So this looks like the key to my new searching.  I know DDE is old for MS but that is about it so far.
0
 
LVL 20

Accepted Solution

by:
darbid73 earned 0 total points
ID: 24881229
The answer is to use DDE and you can then call an Access macro.  An Access macro can call any function.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand column That will then direct you to their download page. From that p…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question