Solved

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

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

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 19

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 19

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 19

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

776 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