Use VB script to run Excel macro

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 ธ.ค. 2024

ความคิดเห็น • 53

  • @IAMDRUIDS
    @IAMDRUIDS 9 ปีที่แล้ว

    2 days looking for a working method for this, and this one worked perfect thanks very much!

  • @TheTomar33
    @TheTomar33 5 ปีที่แล้ว +3

    I couldn't tell what happen after you ran the run.bat youtube place some next videos at the end all over the screen.

  • @yacinejob1592
    @yacinejob1592 3 ปีที่แล้ว

    perfect thanks, i advise to make a pause on the batch to get the errors if any

  • @sabarirajan3821
    @sabarirajan3821 2 ปีที่แล้ว

    what if, the macro method in private ? will the method triggered from vbs ? kindly share your suggestion

  • @VQ35er
    @VQ35er 5 ปีที่แล้ว +1

    Worked great, after a few tries. I managed to type the .xlsm file path wrong at first. By typing pause in a new line in the .bat file I was able to see my error after the file ran, and correct.

  • @gordonhorn554
    @gordonhorn554 4 ปีที่แล้ว

    Can you send/post the vbs script so that I can copy-paste? It's hard to tell if something is a zero or an O, or a comma or a period. Thank you!

  • @AdamikPeter
    @AdamikPeter 9 ปีที่แล้ว +3

    hello, Ive done exactly the same procedure but macro did not run. I mean run.bat is able to run script.vbs then this script is able to open excel, but it cant rund the macro. When i chceck the file I see the macro wasnt realized. Any idea?
    thank you

    • @sabbe14
      @sabbe14 7 ปีที่แล้ว

      mine is not working either... any solutions yet ?

    • @japawenyosports
      @japawenyosports 6 ปีที่แล้ว

      the sample doesn't work if you are running multiple modules. you have to specify which module and which sub. And if it takes time for macro to finish, make sure you put a pause in between to allow the macro to completely finish its run.
      I had used this instead in the vbscript.
      Dim objExcel, xlBook
      Set objExcel = CreateObject("Excel.Application")
      Set xlBook = objExcel.Workbooks.Open ("C:\OTS\tstjovtst_OTS.xlsm")
      objExcel.Visible = True
      objExcel.Run xlBook.name & "!Module3.Sevenam" /mine is in module3, macroname is sevenam/
      WScript.Sleep 100000
      objExcel.ActiveWorkbook.Save
      objExcel.ActiveWorkbook.Close(0)
      objExcel.Quit
      in the batch file simply used:
      cscript sevenam.vbs /filename of the vbs is "sevenam"/

    • @MaxtorMax1
      @MaxtorMax1 6 ปีที่แล้ว +1

      When I run script, I got error:
      Line: 6
      Char: 1
      Error: Subscript out of range
      Code: 800A0009
      Something wrong with line: objExcel.Workbooks.Open args(0)

    • @nonsense1524
      @nonsense1524 6 ปีที่แล้ว

      Dmitriy Preobrazhenskiy check for spell miss

  • @barrankobama4840
    @barrankobama4840 8 ปีที่แล้ว +1

    running
    cscript script.vbs "C:\Test\Book1.xlsm"
    gives me
    Microsoft VBScript runtime error: Wrong number of arguments or invalid property assignment

  • @valigeorge9110
    @valigeorge9110 7 ปีที่แล้ว +1

    Thx for this tut. It works for me and it looks very fancy to me, specially when I set objExcel.Visible = False and everything happens in background. As I recommendation, you can use the PAUSE word in batch file to see if there is an error or if everything worked just fine. What I do not understand is the argument object. What we use that for? Thank you.

    • @valigeorge9110
      @valigeorge9110 7 ปีที่แล้ว

      L.E: I figured out. The args are related to the path and the name of module that we mention in batch file. We can also remove the args object, create 2 string, one containing the path of the workbook and the other one containing the name of the module and we would have: objExcel.Workbooks.Open wkbPath and objExcel.Run modulName. Thx again

  • @wirelad1
    @wirelad1 7 ปีที่แล้ว +1

    Hi - When I run this script / batch file from task scheduler - I see the dos window flash but the micro doesn't run? anybody ideas why? If I run the batch file manually, works fine. thanks

  • @florinradu6815
    @florinradu6815 6 ปีที่แล้ว

    Nice work and great video !!

  • @pratik9217
    @pratik9217 3 ปีที่แล้ว

    I executed the macro by using only vbs but the GetOpenFileName pop-up called in macro is not coming on top of screen-which successfully comes when running the macro independent of the vbs---how to solve this issue?

  • @aninayan3543
    @aninayan3543 5 ปีที่แล้ว

    Thank You Very Much Sir, Its perfectly Working.....

  • @elshaymaanassar5636
    @elshaymaanassar5636 5 ปีที่แล้ว

    how to apply same macro to other xlsm sheet not owner to macro
    or how to make macro public for many xlsm ?

  • @glaciervt
    @glaciervt 7 ปีที่แล้ว +1

    Works perfect, thanks!

  • @gustavfourie1867
    @gustavfourie1867 5 ปีที่แล้ว

    There is no search box on your website. Why dont you add the code here?

  • @IrshadKhan-cf7zu
    @IrshadKhan-cf7zu 4 ปีที่แล้ว

    hello sir i need a vb scropt to find a value from excsl

  • @isalovell
    @isalovell 7 ปีที่แล้ว

    Works perfectly! How can one add multiple Excel files in the same script?

  • @andreas.4456
    @andreas.4456 5 ปีที่แล้ว

    thanks a lot, i have already find find answer for vbs too :). perfect helping video! :)

  • @nonsense1524
    @nonsense1524 6 ปีที่แล้ว +8

    Unable to see last execution

  • @luismey
    @luismey 9 ปีที่แล้ว

    That was perfect! Thank you very much.

  • @MarkFreemanYVR
    @MarkFreemanYVR 6 ปีที่แล้ว +2

    Hey All - Here is the script.vbs code that can be copied and used.
    Dim args, objExcel
    Set objExcel = CreateObject("Excel.Application")
    Set args = wscript.Arguments
    objExcel.Workbooks.Open args(O) ' Capital letter "O"
    objExcel.visible = True
    objExcel.Run "helloworld"
    objExcel.ActiveWorkbook.Save
    ''wscript.sleep 5000 'sleep for 5sec 'this code can be used to pause and check the terminal window activity
    ObjExcel.Activeworkbook.Close(O) ' Capital letter "O"
    ObjExcel.Quit

    • @parasf1121
      @parasf1121 4 ปีที่แล้ว

      You are the real game changer...Thanks Buddy ..

  • @HartGekochteEierProj
    @HartGekochteEierProj 7 ปีที่แล้ว

    Would anyone know how to trigger the macro that is not part of the workbook but is being stored in Personal.xlsb folder?

  • @ayaanansari4765
    @ayaanansari4765 4 ปีที่แล้ว

    Thanks Sir for this tutorial and also tell me know that how can exit .bat with the help of Script that Which is used to run script.vbs

  • @kishore1101981
    @kishore1101981 5 ปีที่แล้ว

    For me the excel is getting is crashed and not getting the output, can you please help...

  • @karinamartinez5029
    @karinamartinez5029 6 ปีที่แล้ว +3

    When I tried to run the VB script I got a Windows Script Host Error, Source: Microsoft VBScript runtime error (Code: 800A0009). Did anyone get the same error? Help, please!

  • @rrrrrr12rr
    @rrrrrr12rr 7 ปีที่แล้ว

    i followed the same convention and process but still i am not getting the results

  • @riyazshaikh6031
    @riyazshaikh6031 3 ปีที่แล้ว

    Actually do u know in an banking application we get birthday alerts using SMS or an Email in that way I want to send an automatic email from excel to group of people
    I will hardcore a date in one of column of excel that is
    1st of every month then
    15th Of every month then
    30th of every month
    An email will shoot when the system reaches to the date specified in the excel column

  • @RPG_ash
    @RPG_ash 8 ปีที่แล้ว +1

    Cool, thanks :]

  • @dimitristomaras3252
    @dimitristomaras3252 8 ปีที่แล้ว

    Thank u!

  • @tonycano8125
    @tonycano8125 8 ปีที่แล้ว

    Thanks!!

  • @roberto-martins
    @roberto-martins 5 ปีที่แล้ว

    Thanks.

  • @paulopenteado3928
    @paulopenteado3928 5 ปีที่แล้ว

    Good!

  • @David-kj1vm
    @David-kj1vm 6 ปีที่แล้ว +1

    didn't work for me

  • @mufniss
    @mufniss 6 ปีที่แล้ว

    Awesome, thanks!

  • @vinodkumarmallah
    @vinodkumarmallah 6 ปีที่แล้ว

    Module is getting deleted automatically

  • @vinodkumarmallah
    @vinodkumarmallah 6 ปีที่แล้ว

    Not working

  • @lafyt2194
    @lafyt2194 4 ปีที่แล้ว

    android

  • @abhishekkshirsagar3734
    @abhishekkshirsagar3734 3 ปีที่แล้ว

    Hi - When I run this script Run.bat file and from task scheduler - I see the dos window flash but the macro doesn't run? anybody ideas why? If I run the file manually, works fine. thanks

  • @patelharikrushn6309
    @patelharikrushn6309 5 ปีที่แล้ว

    It's not working