Solved

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

Posted on 2009-07-15
5
476 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
  • 4
5 Comments
 
LVL 30

Assisted Solution

by:Zoppo
Zoppo earned 100 total points
Comment Utility
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 19

Author Comment

by:darbid73
Comment Utility
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 19

Author Comment

by:darbid73
Comment Utility
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 19

Author Comment

by:darbid73
Comment Utility
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 19

Accepted Solution

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

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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. …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

744 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now