Solved

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

Posted on 2009-07-15
5
480 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 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
EvenOdd challenge 10 127
I could not build boost code, 10 95
Eclipse Neon start with Admin account only 6 143
Capture logon name 13 87
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

828 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