+ Reply to Thread
Results 1 to 29 of 29

macro to run in background

  1. #1
    Registered User
    Join Date
    06-24-2015
    Location
    india
    MS-Off Ver
    7
    Posts
    18

    macro to run in background

    Hello
    I am running a macro which pings different ip address and update result in excel sheet .but when this macro run a black command window continuously appears till the time it compmetes.it doesnot allow me to do other jobs on pc .i want this macro to run continuously without black screen window so that i can work on other program in pc
    Thanks in advance

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Run a macro in background

    Can't you just write vsbscript that writes to a text file? You could then open this in Excel

  3. #3
    Registered User
    Join Date
    06-24-2015
    Location
    india
    MS-Off Ver
    7
    Posts
    18
    Quote Originally Posted by Kyle123 View Post
    Can't you just write vsbscript that writes to a text file? You could then open this in Excel
    Hello
    Dear can u te me what u want me to do shall i post the code

  4. #4
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Run a macro in background

    Please post your code

  5. #5
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Run a macro in background


  6. #6
    Registered User
    Join Date
    06-24-2015
    Location
    india
    MS-Off Ver
    7
    Posts
    18
    Quote Originally Posted by Kyle123 View Post
    Please post your code
    It reads the ip address from sheet and update reachable or unreachable in other column

    Please Login or Register  to view this content.
    Last edited by alansidman; 01-27-2016 at 11:03 AM. Reason: code tags added

  7. #7
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Run a macro in background

    That's what the batch script does in the above link - also, please use code tags when posting code

  8. #8
    Registered User
    Join Date
    06-24-2015
    Location
    india
    MS-Off Ver
    7
    Posts
    18
    Quote Originally Posted by Kyle123 View Post
    That's what the batch script does in the above link - also, please use code tags when posting code
    Kindly explain plz

  9. #9
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Run a macro in background

    No, did you even look at the link?

  10. #10
    Registered User
    Join Date
    06-24-2015
    Location
    india
    MS-Off Ver
    7
    Posts
    18
    Quote Originally Posted by Kyle123 View Post
    No, did you even look at the link?
    I checked but it is a notpad file how can i update it in excel sheet on a particular column

  11. #11
    Registered User
    Join Date
    06-24-2015
    Location
    india
    MS-Off Ver
    7
    Posts
    18
    Quote Originally Posted by joshi868b View Post
    I checked but it is a notpad file how can i update it in excel sheet on a particular column
    Still waiting for your reply plz

  12. #12
    Registered User
    Join Date
    06-24-2015
    Location
    india
    MS-Off Ver
    7
    Posts
    18

    macro to run in background

    What are the command used to avoid black command window which keeps on flickring when macro run

  13. #13
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: macro to run in background

    Try this after your macro name or Dim line(s)
    Please Login or Register  to view this content.
    Then, before end sub try
    Please Login or Register  to view this content.
    1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
    You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.

    Tom

  14. #14
    Registered User
    Join Date
    06-24-2015
    Location
    india
    MS-Off Ver
    7
    Posts
    18
    Quote Originally Posted by gmr4evr1 View Post
    Try this after your macro name or Dim line(s)
    Please Login or Register  to view this content.
    Then, before end sub try
    Please Login or Register  to view this content.
    It doesn't work black screen keep on flickring

  15. #15
    Registered User
    Join Date
    06-24-2015
    Location
    india
    MS-Off Ver
    7
    Posts
    18
    Quote Originally Posted by joshi868b View Post
    It doesn't work black screen keep on flickring
    My code is below
    Please Login or Register  to view this content.
    Last edited by alansidman; 01-27-2016 at 11:04 AM. Reason: code tags added

  16. #16
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: macro to run in background

    Don't forget, anytime you use Application.ScreenUpdating = False at the beginning of your code, you MUST put Application.ScreenUpdating at the end of your code.
    As for it not working, I'm not sure why you keep getting the flickering.
    Could you attach a sample workbook with some data and your code so I can see what is going on with it?

  17. #17
    Registered User
    Join Date
    06-24-2015
    Location
    india
    MS-Off Ver
    7
    Posts
    18
    Quote Originally Posted by gmr4evr1 View Post
    Don't forget, anytime you use Application.ScreenUpdating = False at the beginning of your code, you MUST put Application.ScreenUpdating at the end of your code.
    As for it not working, I'm not sure why you keep getting the flickering.
    Could you attach a sample workbook with some data and your code so I can see what is going on with it?
    It is a simple excel sheet having ip address in column b and results in column c

  18. #18
    Valued Forum Contributor
    Join Date
    11-26-2012
    Location
    Sydney
    MS-Off Ver
    2010
    Posts
    423

    Re: macro to run in background

    Try changing you shell command to this:

    Please Login or Register  to view this content.
    Or you may want to use vbMinimizedNoFocus if you want to be able to see the window.

  19. #19
    Registered User
    Join Date
    06-24-2015
    Location
    india
    MS-Off Ver
    7
    Posts
    18
    Quote Originally Posted by mgs73 View Post
    Try changing you shell command to this:

    Please Login or Register  to view this content.
    Or you may want to use vbMinimizedNoFocus if you want to be able to see the window.
    It is showing some error 450
    Wrong number of argument or invalid property assignment
    Last edited by joshi868b; 01-27-2016 at 05:31 AM.

  20. #20
    Valued Forum Contributor
    Join Date
    11-26-2012
    Location
    Sydney
    MS-Off Ver
    2010
    Posts
    423

    Re: macro to run in background

    How about this:
    Please Login or Register  to view this content.
    or this:
    Please Login or Register  to view this content.
    Hope one or the other works for you - best of luck!

  21. #21
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: macro to run in background

    Welcome to the Forum, unfortunately:

    This is a duplicate post and as such does not comply with Rule 5 of our forum rules. This thread will now be closed, you may continue in your other thread.

  22. #22
    Forum Contributor
    Join Date
    09-03-2015
    Location
    IE
    MS-Off Ver
    2003 - 2016
    Posts
    258

    Re: Run a macro in background

    You cannot hide the Command Window that appears using wshShell.Exec. You can if you use wshShell.Run but that does not support reading the output via StdOut.ReadAll, you would have to redirect the output to a file and read that.

    Live with the flashing window for simplicity.

  23. #23
    Registered User
    Join Date
    06-24-2015
    Location
    india
    MS-Off Ver
    7
    Posts
    18
    Quote Originally Posted by mgs73 View Post
    How about this:
    Please Login or Register  to view this content.
    or this:
    Please Login or Register  to view this content.
    Hope one or the other works for you - best of luck!
    Not working

  24. #24
    Forum Contributor
    Join Date
    09-03-2015
    Location
    IE
    MS-Off Ver
    2003 - 2016
    Posts
    258

    Re: macro to run in background

    It won't work - seeing the comment in post 10, I suggest you check your other thread.

  25. #25
    Registered User
    Join Date
    06-24-2015
    Location
    india
    MS-Off Ver
    7
    Posts
    18
    Quote Originally Posted by grimes0332 View Post
    You cannot hide the Command Window that appears using wshShell.Exec. You can if you use wshShell.Run but that does not support reading the output via StdOut.ReadAll, you would have to redirect the output to a file and read that.

    Live with the flashing window for simplicity.
    Dear Grimes pleaz tell me full procedure i m new to this

  26. #26
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,705

    Re: macro to run in background

    @joshi868b

    Please read the forum rules. You have violated two of them. Don't duplicate posts. Use Code tags. I have added the code tags for you and have merged your two posts into this one. Please read the forum rules and abide by them in the future. Future violations of these rules may result in infractions.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  27. #27
    Registered User
    Join Date
    06-24-2015
    Location
    india
    MS-Off Ver
    7
    Posts
    18
    Quote Originally Posted by alansidman View Post
    @joshi868b

    Please read the forum rules. You have violated two of them. Don't duplicate posts. Use Code tags. I have added the code tags for you and have merged your two posts into this one. Please read the forum rules and abide by them in the future. Future violations of these rules may result in infractions.
    I am sorry for violating the rules beacause of my ignorance kindly send a link of rules so that i will keep the forum rule paramount.

  28. #28
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,705

    Re: macro to run in background

    See attachedCapture.PNG

  29. #29
    Registered User
    Join Date
    09-15-2014
    Location
    michigan
    MS-Off Ver
    2003
    Posts
    94

    Re: macro to run in background

    the way you will need to do this is open notepad and paste
    Please Login or Register  to view this content.
    it the notepad save the file as c:\invisible.vbs c:\ being your root drive or a folder of your choosing but I recommend it be a system folder
    then have excel run the ping command using
    Please Login or Register  to view this content.
    but the problem with this is you no longer have an output for excel to look at you cant do what your doing with out the command window popping up
    the command window pops up because there is an output you can suppress the command window but then there is no output and excel gets no data
    im still new to vbs but if there was a way to suppress the window output and save it to a text you may be able to do it that way.
    I know from the command prompt if you
    Please Login or Register  to view this content.
    it will save the ping output to a text file but the window will still come up.
    I just don't think what your asking is possible but I could be wrong
    windows 7 x64 excell 2003 still learning vbs

+ 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. Can a macro run in the background?
    By mglwd40 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-06-2013, 10:19 PM
  2. [SOLVED] Macro to change all cells with a certain background color in another background color
    By kevinvzandvoort in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-13-2012, 11:04 AM
  3. How to work with macro in background
    By Jared in forum Excel General
    Replies: 2
    Last Post: 08-13-2006, 11:55 PM
  4. [SOLVED] How do I run a macro in the background
    By scrumboss in forum Excel General
    Replies: 2
    Last Post: 04-06-2006, 05:55 AM
  5. Run Macro in background
    By freekrill in forum Excel General
    Replies: 0
    Last Post: 05-11-2005, 02:24 AM
  6. Run Macro in the background
    By banavas in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-01-2005, 07:16 AM

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