Macro in one location and file to run the macro in another locatio

L

ldiaz

I running this macro from excel.

but the problem is that the macro is stored in the same file where I need to
run the macro and it will be replaced every day,
what I need is to create a new excel book with the macro inside, then run
this macro to open another excel , execute macro, save and close the file.

please help.

===============================================

Private Sub RunEMac_Click()

Dim xls As Object, xwkb As Object
Dim strFile As String, strMacro As String
strFile = "CurrentDispatch.xls"
strMacro = "Shipping"
Set xls = CreateObject("Excel.Application")
xls.Visible = True
Set xwkb = xls.Workbooks.Open("C:\Documents and Settings\ldiaz\My
Documents\Shipping System\" & strFile)
xls.Run strFile & "!" & strMacro
xwkb.Close False
Set xwkb = Nothing
xls.Quit
Set xls = 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