• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Run Excel VBA from VBscript

YasserKhalil

Well-Known Member
Hello forum members
I am trying to run this vbs file
Code:
Dim xl
Dim xlBook     
Dim sCurPath
path = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".")
Set xl = CreateObject("Excel.application")
Set xlBook = xl.Workbooks.Open(path & "\Run Macro From Outside Excel.xlsm", 0, True)     
xl.Application.Visible = False
xl.DisplayAlerts = False   
xl.Application.run "Test"
xlBook.Save
xl.ActiveWindow.Close
xl.Quit
Set xlBook = Nothing
Set xl = Nothing

and this is the macro inside the vbe
Code:
Sub Test()
    Sheets("Sheet1").Range("A1").Value = Now()
    MsgBox "Hello Everyone"
End Sub

It works well but doesn't save the changes .. It would save the value in A1
Any ideas?
 
Thanks a lot Mr. Hui and Mr. Debaser
You're right Mr. Debaser
After changing True to False it works as expected
Thank you very much
 
Back
Top