Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Executing an Excel Macro in Access

Status
Not open for further replies.

kvogt2

Technical User
Oct 29, 2002
6
0
0
US
Everyone,

Currently I am attempting to open a designated excel workbook, execute a macro contained in that workbook, then save and close the workbook via VBA in Access. This is the code I currently have:

Public Sub RunExcel()

Dim objExcel As New Excel.Application
Dim objExcelDoc As Object

Set objExcel = New Excel.Application

Set objExcelDoc = objExcel.Workbooks.Open("WorkbookX")
objExcel.Visible = True

With objExcel
.Run ("MacroX")
End With

objExcel.ActiveWorkbook.Close savechanges:=True
objExcel.Quit

End Sub

When I attempt to call this code in an access macro, this error appears:
"The expression you entered contains a function name that Microsoft Access can't find"

I would appreciate any suggestions / assistance.

kevin v.
 
Nevermind, I figured it out:

I forgot to add a function to call the sub procedure:

Function Call_RunExcel()
RunExcel
End Function

Now it works...

kevin v.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top