Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Cam Cam is offline
external usenet poster
 
Posts: 165
Default Automating macro to run macro from Access

Hello,

I have an Excel file with several sheets of data from source in Access
macro. What is the macro code to call the macro named "CreateData" in Access
macro, then run refresh all in Excel to refresh all worksheets?
The manual way I am doing right now is:
1) Open Access file, then run the macro named "CreateData"
2) Open Excel file, then run an Excel macro called "Refresh" to refresh all
worksheets.

Would like to perform all at once in Excel. Thank you
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 236
Default Automating macro to run macro from Access

'/=======================================/
' Sub Purpose: run MS Access macro or procedure
' from Access in Excel
' Reference to MS Access not required - late binding
'/=======================================/
'
Public Sub CallFromMSAccess()
Dim appAccess As Object
Dim strDatabaseLocation As String

On Error GoTo err_Sub

'- - - - V A R I A B L E S - - - - - -
strDatabaseLocation = "C:\Temp\db1.mdb"
'- - - - - - - - - - - - - - - - - - -

'open an instance of Microsoft Access and a database
Set appAccess = CreateObject("Access.Application")
appAccess.OpenCurrentDatabase strDatabaseLocation

'run an Access MACRO
appAccess.DoCmd.RunMacro "MyMacro"

'run an Access PROCEDURE
appAccess.Run "MyProcedure"

exit_Sub:
On Error Resume Next
'close Microsoft Access
appAccess.Quit
Set appAccess = Nothing
Exit Sub

err_Sub:
Debug.Print "Error: " & Err.Number & " - (" & _
Err.Description & ") - " & Now()
GoTo exit_Sub

End Sub
'/=======================================/


--
Hope this helps.
If it does, please click the Yes button.
Thanks in advance for your feedback.
Gary Brown



"Cam" wrote:

Hello,

I have an Excel file with several sheets of data from source in Access
macro. What is the macro code to call the macro named "CreateData" in Access
macro, then run refresh all in Excel to refresh all worksheets?
The manual way I am doing right now is:
1) Open Access file, then run the macro named "CreateData"
2) Open Excel file, then run an Excel macro called "Refresh" to refresh all
worksheets.

Would like to perform all at once in Excel. Thank you

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 236
Default Automating macro to run macro from Access

Public Sub Calc_Workbook()
'calculate entire workbook - [F9]
Application.Calculate
' MsgBox "The entire workbook has been recalculated."
End Sub

--
Hope this helps.
If it does, please click the Yes button.
Thanks in advance for your feedback.
Gary Brown



"Cam" wrote:

Hello,

I have an Excel file with several sheets of data from source in Access
macro. What is the macro code to call the macro named "CreateData" in Access
macro, then run refresh all in Excel to refresh all worksheets?
The manual way I am doing right now is:
1) Open Access file, then run the macro named "CreateData"
2) Open Excel file, then run an Excel macro called "Refresh" to refresh all
worksheets.

Would like to perform all at once in Excel. Thank you

  #4   Report Post  
Posted to microsoft.public.excel.programming
Cam Cam is offline
external usenet poster
 
Posts: 165
Default Automating macro to run macro from Access

Hello Gary,

Thanks for your help. A question I am not sure what is it in the code.

'run an Access PROCEDURE
appAccess.Run "MyProcedure"

I am not sure what procedure is it. Also your second response, what is it
function?


"Gary Brown" wrote:

'/=======================================/
' Sub Purpose: run MS Access macro or procedure
' from Access in Excel
' Reference to MS Access not required - late binding
'/=======================================/
'
Public Sub CallFromMSAccess()
Dim appAccess As Object
Dim strDatabaseLocation As String

On Error GoTo err_Sub

'- - - - V A R I A B L E S - - - - - -
strDatabaseLocation = "C:\Temp\db1.mdb"
'- - - - - - - - - - - - - - - - - - -

'open an instance of Microsoft Access and a database
Set appAccess = CreateObject("Access.Application")
appAccess.OpenCurrentDatabase strDatabaseLocation

'run an Access MACRO
appAccess.DoCmd.RunMacro "MyMacro"

'run an Access PROCEDURE
appAccess.Run "MyProcedure"

exit_Sub:
On Error Resume Next
'close Microsoft Access
appAccess.Quit
Set appAccess = Nothing
Exit Sub

err_Sub:
Debug.Print "Error: " & Err.Number & " - (" & _
Err.Description & ") - " & Now()
GoTo exit_Sub

End Sub
'/=======================================/


--
Hope this helps.
If it does, please click the Yes button.
Thanks in advance for your feedback.
Gary Brown



"Cam" wrote:

Hello,

I have an Excel file with several sheets of data from source in Access
macro. What is the macro code to call the macro named "CreateData" in Access
macro, then run refresh all in Excel to refresh all worksheets?
The manual way I am doing right now is:
1) Open Access file, then run the macro named "CreateData"
2) Open Excel file, then run an Excel macro called "Refresh" to refresh all
worksheets.

Would like to perform all at once in Excel. Thank you

Reply
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
Help with automating macro Cam Excel Programming 17 December 4th 08 09:21 PM
Automating Input during a macro.... Centurius Excel Programming 1 September 22nd 06 02:08 PM
New to VBA..need help with automating GETSAVEAS Macro in Excel 2003 xphile Excel Programming 1 January 22nd 06 05:37 AM
automating macro chris Excel Programming 2 April 25th 05 05:17 PM
Frequently used macro-automating? Ben Kingsley Excel Programming 0 September 17th 03 05:53 PM


All times are GMT +1. The time now is 10:56 AM.

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

About Us

"It's about Microsoft Excel"