LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 149
Default Run Access Macro from within Excel

No. You are using the object model to write the code that will open Access
itself and run an Access macro within Access.

Gotta have the Access engine to do that. Same thing if you wanted to run an
Access report: you'd need the Access engine. The object model contains no
app-like capabilities, just simply provides you the means to write code that
will manipulate the app.

Of course, data can be retrieved without having Access itself using the
Access, DAO, ADO, etc. object models. Queries or other SQL can be retrieved
and *possibly* even run without having Access open. One gotcha would be if
any Access-specific or user-defined functions are used in queries, you'd
probably need to run the queries in Access or be prepared to make
substitutions. An example of this is NZ() (Null to zero). That's an Access
function, not a VB function, so if VB (or Jet) encounters it without Access
open to provide interpretation, you're going to get an "undefined function"
error.

HTH,


"Amery" wrote in message
...
Is there a way to use this code if the person has the object Library, but
not
Access itself?

"Eric White" wrote:

The easiest way is to set a reference in your Excel project to the Access
object library. (Tools - References, and scroll down to find "Microsoft
Access XX.0 Object Library," and check the box.) This will allow you to
get
all the Intellisense features for Access. So, in Excel

Sub RunAccessMacro()

Dim appAcc as Access.Application

'Opens Access or gets reference to app already running
Set appAcc = New Access.Application

'Optional to show or hide Access
appAcc.Visible = True

appAcc.Open "C:\Database with the Macro.mdb"


'For running a regular Access macro
appAcc.DoCmd.RunMacro "MyAccessMacro"

'For running a VBA macro
appAcc.RunMacro "MyAccessMacro"

'MORE OF YOUR CODE

'Close Access
appAcc.Quit

'This will close Access, even w/o the 'Quit' command
Set appAcc = Nothing

End Sub



"Thebeej" wrote:

I am new to macro programming. It is possible to run an Access Macro
from an
Excel spreadsheet? Can you open Access, run the macro, close Access
from the
spreadsheet?



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Call an Access macro from an Excel macro Jason W Excel Discussion (Misc queries) 1 May 1st 08 08:33 PM
Trigger a Macro in MS Access from an Excel Macro? DonRetd Excel Programming 13 March 30th 05 09:52 PM
Excel Macro with Access Daniel Barelli Excel Programming 1 October 25th 04 10:07 PM
Macro to get from excel into Access andycharger[_18_] Excel Programming 0 March 5th 04 10:00 AM
Launch Macro in Access via Macro running in Excel??? dgrant Excel Programming 1 September 24th 03 01:38 PM


All times are GMT +1. The time now is 08:49 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"