Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2009-07-15
5
Medium Priority
?
486 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 400 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

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…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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 synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

636 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