+ Reply to Thread
Results 1 to 26 of 26

Clearing the Immediate window?

  1. #1
    Forum Contributor terrypin's Avatar
    Join Date
    01-06-2010
    Location
    East Grinstead, UK
    MS-Off Ver
    MS Office 365
    Posts
    533

    Clearing the Immediate window?

    As a VBA novice I'm frequently trying to see what is happening to the variables I'm using. When there are many of them, as in the code below, the msgBox method (my preference) cannot be used because I understand it has a 1024 character limit.
    Q1: Is there any way to extend that?

    Q2: Assuming not, if instead I use debug.Print is there a statement that will clear it entirely, to avoid doing it manually please?

    Q3: Is another alternative possible, such as saving a small text file and then automatically viewing that?

    Please Login or Register  to view this content.
    Terry, East Grinstead, UK
    Excel 365, Win 10 Pro, i7 PC, 4.0 GHz

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,434

    Re: Clearing the Immediate window?

    No built in command to clear the debug window. You could use sendkeys, if you are brave.
    Or write a function to fill the window with blank lines. 250 should do it. But if the cursor in the immediate window is not at the end you will still have text below the cursor.

    I believe MZ-Tools offers this feature, but it costs $$

    Personally I would use a worksheet and some code that takes a ParamArray so a variable number of arguments can be handle.
    Each write adds a new row and each argument is written to a cell.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,428

    Re: Clearing the Immediate window?

    Ctrl-a Delete is hardly arduous ...

    Personally, I wouldn’t try to display 21 variables, bit hard to take in. And I wouldn’t have new lines between each of them ... all depends on the content I guess.

    Writing them to a worksheet is one option, but you probably need to date and time stamp the entries.

    You could use Print or Write to update a text file.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Forum Contributor terrypin's Avatar
    Join Date
    01-06-2010
    Location
    East Grinstead, UK
    MS-Off Ver
    MS Office 365
    Posts
    533

    Re: Clearing the Immediate window?

    Thanks Andy. Pity, a Clear would be handy! I may explore your ParamArray suggestion, although that's new territory.

  5. #5
    Forum Contributor terrypin's Avatar
    Join Date
    01-06-2010
    Location
    East Grinstead, UK
    MS-Off Ver
    MS Office 365
    Posts
    533

    Re: Clearing the Immediate window?

    Thanks TMS. I agree, but I frequently forget to do it. And without those newlines it's even harder 'to take in'!

    I'll investigate Print and Write later.

  6. #6
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: Clearing the Immediate window?

    Or You can use different type of MsgBox:
    Try to:

    Please Login or Register  to view this content.
    look on pictures (try to display range A1:Y40):
    Capture.JPG
    Captur11111e.JPG
    Happy with my answer * Add Reputation.
    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

  7. #7
    Forum Contributor terrypin's Avatar
    Join Date
    01-06-2010
    Location
    East Grinstead, UK
    MS-Off Ver
    MS Office 365
    Posts
    533

    Re: Clearing the Immediate window?

    Thanks KOKOSEK. That looks interesting, and I ran a simple small example OK.

    But I don't really understand how you displayed that large message. And I assume it has the same 1024 character limit as a normal MsgBox.

    Could you show a sub that makes it clearer please?

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,428

    Re: Clearing the Immediate window?

    Please Login or Register  to view this content.

  9. #9
    Forum Expert BMV's Avatar
    Join Date
    01-13-2020
    Location
    St-Petersburg, Russia
    MS-Off Ver
    2013-2016
    Posts
    1,329

    Re: Clearing the Immediate window?

    terrypin, If you use it for debug then you can place this data to an additional work sheet. I think navigation and control will be easy then looking at the large message box.
    Even text box in a worksheet or on the form will be more useful.

  10. #10
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: Clearing the Immediate window?

    The same range has not been displayed in standard msgbox (limited space) and been displayed in shell msgbox.
    @terrypin - I don not know what is not clear for you.

    Once more....

    1.JPG
    2.JPG

    EDIT: TMS shows the way meantime

  11. #11
    Forum Contributor terrypin's Avatar
    Join Date
    01-06-2010
    Location
    East Grinstead, UK
    MS-Off Ver
    MS Office 365
    Posts
    533

    Re: Clearing the Immediate window?

    TMS, KOKOSEK,

    Thanks both, got it.

    How do you resize and reposition the window?
    Last edited by terrypin; 02-09-2020 at 10:53 AM.

  12. #12
    Forum Contributor terrypin's Avatar
    Join Date
    01-06-2010
    Location
    East Grinstead, UK
    MS-Off Ver
    MS Office 365
    Posts
    533

    Re: Clearing the Immediate window?

    Thanks BMV, neat idea. I just added the line

    Please Login or Register  to view this content.
    and as you suggested that gave a more convenient display.

  13. #13
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: Clearing the Immediate window?

    Quote Originally Posted by terrypin View Post
    THow do you resize and reposition the window?
    There does not appear to be a way to do that. Here is a link to webpage giving a pretty extensive description (in about a little more than the first 1/3 of that webpage) of how to program the PopUp method for WScript.Shell...

    http://www.informit.com/articles/art...87429&seqNum=5

  14. #14
    Forum Contributor terrypin's Avatar
    Join Date
    01-06-2010
    Location
    East Grinstead, UK
    MS-Off Ver
    MS Office 365
    Posts
    533

    Re: Clearing the Immediate window?

    One puzzle. I added another couple of lines so that it would automatically size the cell containing the message. But although it gets the height correct, the width is wrong.

    It's very easy to do manually (although strangely even that isn't perfect) but I'm curious why the macro doesn't work.

    Please Login or Register  to view this content.
    Attached Images Attached Images

  15. #15
    Forum Contributor terrypin's Avatar
    Join Date
    01-06-2010
    Location
    East Grinstead, UK
    MS-Off Ver
    MS Office 365
    Posts
    533

    Re: Clearing the Immediate window?

    Thanks Rick, studying that now. Pity its dimensions can't be changed. And at first reading it seems more complicated to setup than in KOKOSEK's simple
    Please Login or Register  to view this content.

  16. #16
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: Clearing the Immediate window?

    Quote Originally Posted by terrypin View Post
    And at first reading it seems more complicated to setup than in KOKOSEK's simple
    Please Login or Register  to view this content.
    It is the same thing... KOKOSEK simply left out all of the possible optional arguments, that is all. For your current needs, you appear not to need the optional arguments, but knowing they are available could be useful if you decide to use it in the future.

  17. #17
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Clearing the Immediate window?

    Quote Originally Posted by terrypin View Post
    ... how ... displayed ... large message ...
    1. Clearing the Intermediate Window:

    https://www.excelforum.com/excel-pro...ow-in-vba.html

    2. For "message output" -> use ordinary notepad for that ... nice fun ... "hardcore game" ...
    (only that on new windows (8, 10) "DataObject" may not work)

    Please Login or Register  to view this content.
    Last edited by mjr veverka; 02-09-2020 at 08:46 PM.

  18. #18
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: Clearing the Immediate window?

    Quote Originally Posted by porucha vevrku View Post
    2. For "message output" -> use ordinary notepad for that ... nice fun ... "hardcore game" ...
    (only that on new windows (8, 10) "DataObject" may not work)
    Your are correct... your display_message subroutine did not work on my Window 8 system. However, if you are willing to tolerate a file being written to the c:\temp folder and then deleted from it, this replacement code for your display_message subroutine should work on any system so long as the c: drive has a folder named "temp" (which I believe is standard. Of course, we could modify the code to create a directory, store the file there, load it into Notepad and then delete the file and then the folder, but I decided not to do that for this demo. Anyway, here is the replace code I am suggesting...
    Please Login or Register  to view this content.
    Note: The file name should be something that won't ever exist in the folder... here I used my nickname with the word Temp inserted between the letters.

  19. #19
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,610

    Re: Clearing the Immediate window?

    Are you avoiding the Watch Window on purpose?
    Ben Van Johnson

  20. #20
    Forum Expert BMV's Avatar
    Join Date
    01-13-2020
    Location
    St-Petersburg, Russia
    MS-Off Ver
    2013-2016
    Posts
    1,329

    Re: Clearing the Immediate window?

    Quote Originally Posted by terrypin View Post
    Thanks BMV, neat idea. I just added the line
    I mean
    Please Login or Register  to view this content.
    If you need split message by column, it could be done also.

  21. #21
    Registered User
    Join Date
    09-15-2019
    Location
    Gurgaon, India
    MS-Off Ver
    2003 2007 2010
    Posts
    8

    Re: Clearing the Immediate window?

    Quote Originally Posted by terrypin View Post
    Clearing the Immediate window?
    Like also Andy Pope is saying, not always good to use send keys.
    But following is another alternative I use, working for me mostly.

    Open file, Tel U Wot , button press.
    ( Tel U Wot button for macro Sub ImmediateWindowOpenClearCloseProgramatically() is )
    ( If VB Editor window is open already, then you must run from within VB Editor instead)


    Macro Sub ImmediateWindowOpenClearCloseProgramatically() will open Immediate window with some text in it, then it will clear immediate window, then it will close it. ( It does do that for me , anyway is doing usually is )
    There are a few bugs associated with bringing various windows and shapes up. These can often be worked around using some known techniques. These have been applied in the uploaded solution
    Attached Files Attached Files
    Last edited by DevelopmentTest; 02-10-2020 at 07:21 AM.

  22. #22
    Forum Contributor terrypin's Avatar
    Join Date
    01-06-2010
    Location
    East Grinstead, UK
    MS-Off Ver
    MS Office 365
    Posts
    533

    Re: Clearing the Immediate window?

    Quote Originally Posted by Rick Rothstein View Post
    It is the same thing... KOKOSEK simply left out all of the possible optional arguments, that is all. For your current needs, you appear not to need the optional arguments, but knowing they are available could be useful if you decide to use it in the future.
    But KOKOSEK's code didn't include
    Please Login or Register  to view this content.
    which that article seems to say is needed?

    If I add that I get "Run-time error '424': Object required", with that line highlighted.

  23. #23
    Forum Expert BMV's Avatar
    Join Date
    01-13-2020
    Location
    St-Petersburg, Russia
    MS-Off Ver
    2013-2016
    Posts
    1,329

    Re: Clearing the Immediate window?

    Please Login or Register  to view this content.
    WScript - it's object from VBS script

  24. #24
    Forum Contributor terrypin's Avatar
    Join Date
    01-06-2010
    Location
    East Grinstead, UK
    MS-Off Ver
    MS Office 365
    Posts
    533

    Re: Clearing the Immediate window?

    Quote Originally Posted by protonLeah View Post
    Are you avoiding the Watch Window on purpose?
    Thanks Ben, never used that but studying it now and will experiment. Appreciate the heads up!

  25. #25
    Forum Contributor terrypin's Avatar
    Join Date
    01-06-2010
    Location
    East Grinstead, UK
    MS-Off Ver
    MS Office 365
    Posts
    533

    Re: Clearing the Immediate window?

    Thanks DevelopmentTest, playing with that now.

  26. #26
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Clearing the Immediate window?

    Quote Originally Posted by Rick Rothstein View Post
    ... a file being written to the c:\temp folder and then deleted from it ...
    Ok, that's good

    Quote Originally Posted by terrypin View Post
    ... but studying it now and will experiment ...
    We could, if someone likes html, to make output to a blank browser page (the simplest html document or data table)
    Attached Files Attached Files
    Last edited by mjr veverka; 02-10-2020 at 01:53 PM.

+ 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] Clearing the Intermediate Window in VBA
    By CaptMac in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-11-2017, 01:27 AM
  2. Switch from Active Window to Variable Window/Rename Varaible Sheet
    By CravingGod in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-04-2016, 09:52 AM
  3. [SOLVED] Copy Tables from IE window to Excel - Need help making code see already opened window
    By mattyp in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-27-2015, 08:14 AM
  4. [SOLVED] How to show both Project Explorer and Code window in the VB window?
    By m3atball in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-02-2014, 07:22 PM
  5. Replies: 2
    Last Post: 09-11-2013, 04:35 AM
  6. [SOLVED] Module works on window XP but not window 7 (using same Excel 2007)
    By wongwlv in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-23-2012, 12:32 AM
  7. Replies: 4
    Last Post: 02-17-2011, 08:29 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