Clearing Immediate Window

Paul Sansom

Board Regular
Joined
Jan 28, 2013
Messages
178
Office Version
  1. 2021
  2. 2016
Platform
  1. Windows
Hi
Any guidance on why Line 1 (Application.) works when used in isolation but not in my test sub.
Objective - Clear the Immediate window each time i run test during development?
Cheers Paul

Code:
Sub Test()
    Application.SendKeys "^g ^a {DEL}"
       
    Dim fDialog As FileDialog, result As Integer
    Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
    
    'IMPORTANT!
        fDialog.AllowMultiSelect = True
     
    'Optional FileDialog properties
        fDialog.Title = "Select a file"
        fDialog.InitialFileName = "C:\Users\Paul\Pictures\Captures"
    
    'Optional: Add filters
        fDialog.Filters.Clear
        'fDialog.Filters.Add "Excel files", "*.xlsx"
        'fDialog.Filters.Add "All files", "*.*"
     
    'Show the dialog. -1 means success!
    If fDialog.Show = -1 Then
        For Each file In fDialog.SelectedItems
            fn = fn + 1
            fn = Format(fn, "0000")
            extFind = Right$(file, Len(file) - InStrRev(file, "."))
            filesavename = Sheet9.Range("N64") & fn & " ." & extFind
            'Debug.Print file
            Debug.Print filesavename
        Next file
    End If
End Sub
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Rather than SendKeys(), maybe overwriting it would suffice?
Code:
Debug.Print String(200, Chr(10))
 
Upvote 0
Hi
Any guidance on why Line 1 (Application.) works when used in isolation but not in my test sub.
Code:
Sub Test()
    Application.SendKeys "^g ^a {DEL}"
    ......
    ......
When used in isolation, meaning inside the VB editor, the VB editor window is the active window... when running your macro, it, not the VB editor window, is the active window. SendKeys sends its output to the active window. What Kenneth posted is a possible work-around, but note that it does not "clear" the Immediate Window, rather, it fills it with Line Feeds meaning the Immediate Window has 200 blank lines in it afterwards (scroll and click around the different rows after running his code to see what I mean).
 
Upvote 0
Hi Rob & Rick
Yes that sort of works. It does overwrite with blank lines, but i have to scroll down each time to find the new file names.
Not quite as clean as clearing the window on each test run
Paul
 
Upvote 0

Forum statistics

Threads
1,217,134
Messages
6,134,844
Members
449,893
Latest member
des378

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top