autorun macro from access

D

Daniel M

I have a macro i have created in excel and I have an access db that i want to
call an excel file run this macro against it.

Now i do not want to run this macro from my personal.xls or have to drop
this in the xlstart folder. what i would like is to just create a macro.xls
file with the macros in and when i call excel from access open the
"logfile.xls" and run a macro on it from the "macro.xls" file. Alternately if
i can copy the macro from access to excel when opening "logfile.xls" that
would work to.

The logfile.xls comes from another person without any macros in it. i format
the file with my macro and resave it. but i want to do this from access.
further i want to copy this to the server so that anyone can do this by
hitting the command button, so it cannot reside on my local machine.

Any ideas?

I have the following code in access but it doesnt even seem to open the file
with my personal.xls.


Private Sub Command3_Click()
Dim objXL As Object, x
On Error Resume Next
Set objXL = CreateObject("Excel.Application")
With objXL.Application
.Visible = True
'Open the Workbook
.Workbooks.Open "C:\testlog.XLS"
.ActiveWorkbook.RunAutoMacros xlAutoOpen
x = .Run("log2sms", 0)
End With
Set objXL = Nothing

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top