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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS Access to open Excel and run a macro in Excel

Status
Not open for further replies.

gmillerinc

IS-IT--Management
Aug 27, 2003
28
US
The title is self-explanatory to what I need. I need Access to open MS Excel and run a macro that exists already in Excel in the process. Any ideas?
 
This actually includes more than your basic question, use what you need. Good-Luck.
Dim xFile As Excel.Application
Dim Mypath2 As String
Dim Mypath As String
Dim FldNme As String
Dim FLENme As String
Dim brunning As Boolean
Dim ExcelWasRunning As Boolean
Me.Refresh
Set RegNme = DBEngine(0).Databases(0).OpenRecordset("tblregistrantname")
FldNme = RegNme!FolderName
FLENme = RegNme!AuditName
Mypath = "C:\My Documents\" + FldNme
Mypath2 = Mypath + "\" + FLENme + ".xls"

On Error Resume Next

Set xFile = GetObject(, "Excel.Application")
If Err.Number = 0 Then ExcelWasRunning = True
xFile.ActiveWorkbook.Close savechanges:=True
Err.Clear
If xFile Is Nothing Then
Set xFile = CreateObject("Excel.Application")
brunning = False
End If

xFile.Workbooks.Open "C:\Program Files\Microsoft Office\Office10\XLstart\Personal.xls"
xFile.ActiveWindow.Visible = False
xFile.Visible = True
xFile.Workbooks.Open Mypath2
xFile.run("MacroLocation.xls!YourMacroName")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top