+ Reply to Thread
Results 1 to 7 of 7

run macro from command prompt

  1. #1
    Registered User
    Join Date
    02-05-2014
    Location
    Malang
    MS-Off Ver
    Excel 2007
    Posts
    33

    run macro from command prompt

    hi everyone,
    i want to run my code in excel vba by using cmd (command prompt).
    i've tried some code that i get from the internet but it still didn't work.
    is it really possible?
    here is my macro

    Please Login or Register  to view this content.
    And here is my code

    Please Login or Register  to view this content.
    Thanks

  2. #2
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: run macro from command prompt

    I don't follow. Could you explain further? What's the RunMacro code in z.xlsm for?

  3. #3
    Forum Contributor S O's Avatar
    Join Date
    06-25-2015
    Location
    England
    MS-Off Ver
    Office 2010 + 2013 + 2016
    Posts
    103

    Re: run macro from command prompt

    Is there a particular reason you want to do this in CMD? It would be easier from WScript or Powershell...

  4. #4
    Registered User
    Join Date
    02-05-2014
    Location
    Malang
    MS-Off Ver
    Excel 2007
    Posts
    33

    Re: run macro from command prompt

    @berlan : Module.RunMacro is the script to run the macro in z.xlsm from vbs. That's what i read on the internet. Thanks
    @ S O : yeah, because in the future i want to make some programs that run automatically by using task scheduler in windows. But if WScript or Powershell could do it, then i'll have to try them as well. Thanks

  5. #5
    Forum Contributor S O's Avatar
    Join Date
    06-25-2015
    Location
    England
    MS-Off Ver
    Office 2010 + 2013 + 2016
    Posts
    103

    Re: run macro from command prompt

    You can use the code you've got up there in a VBScript, it should literally copy and paste over with no issues - you can then run the VBS file from task scheduler, or even call it from CMD like:

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    02-05-2014
    Location
    Malang
    MS-Off Ver
    Excel 2007
    Posts
    33

    Re: run macro from command prompt

    i've tried my code above but it just open the workbook and didn't run the macro.
    how do i make the code run my macro?
    by the way could u post the WScript and Powershell script so i could try and compare them.
    and is it possible just to run the macro without opening the "excel" file
    Thanks
    Last edited by uniks; 10-22-2015 at 10:26 PM.

  7. #7
    Registered User
    Join Date
    02-05-2014
    Location
    Malang
    MS-Off Ver
    Excel 2007
    Posts
    33

    Re: run macro from command prompt

    after some research this is the code that work
    Please Login or Register  to view this content.
    note : i run this code from Powershell so you have to save it in a '.PS1' file to run it

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Run Command Prompt Icacls code in VBA Command Button on Userform
    By luismalave in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-19-2015, 11:40 PM
  2. How to run a set of commands in command prompt using vba
    By A N Rahman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-14-2015, 09:05 AM
  3. Command Prompt through Excel
    By Sniper in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-28-2012, 07:07 AM
  4. Command Prompt Window - VBA
    By erock24 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-16-2011, 10:44 AM
  5. Command Prompt = Crashed Macro
    By jkelly228 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-13-2011, 11:38 AM
  6. Refresh workbook from command prompt
    By gucci in forum Excel General
    Replies: 1
    Last Post: 04-22-2007, 01:54 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1