Clearing Immediate window in VBA by code

A

Adrian C

Mike said:
I read that in your last post and Googled it but got no clues

Goto Tools - Macro - Security - Trusted Publishers tab.

Check the box "Trust Acces to Visual Basic Project"
 
R

Rick Rothstein \(MVP - VB\)

Okay, that worked. Thanks.

A question, though... since that option's default was to be unchecked (at
least, I'm assuming that since I never visited that tab before), what
"dangers" does checking it open my system up to?

Rick
 
J

Jim Rech

Back in the day when "macro viruses" were all the rage they sometimes
propagated programming the VBE itself. I think the misanthropes have mostly
moved to the web so not a great deal to worry about, and you can always
disable all macros when opening a workbook.

--
Jim
message | Okay, that worked. Thanks.
|
| A question, though... since that option's default was to be unchecked (at
| least, I'm assuming that since I never visited that tab before), what
| "dangers" does checking it open my system up to?
|
| Rick
|
|
| | > In xl2003 menu system:
| > Tools|Macro|Security|Trusted Publishers tab
| > Check "Trust access to Visual Basic Project"
| >
| >
| >
| > "Rick Rothstein (MVP - VB)" wrote:
| >>
| >> Hmm! When I try that, I keep getting this message... "No Access to
Visual
| >> Basic Project".
| >>
| >> Rick
| >>
| >> | >> >I put it in an ordinary module then called it with this in sheet1 code
| >> >window
| >> > to test it
| >> >
| >> > Sub stance()
| >> > Dim x As Long
| >> > For x = 1 To 10
| >> > Debug.Print x
| >> > Next
| >> > ClearImmediateWindow
| >> > End Sub
| >> >
| >> > Mike
| >> >
| >> > "Rick Rothstein (MVP - VB)" wrote:
| >> >
| >> >> Where are you running it from? I tried placing it in a Sheet's code
| >> >> window
| >> >> (as a macro) and running it either directly from there using the Run
| >> >> button
| >> >> or from a worksheet using Alt+F8. I also tried running it from the
| >> >> Click
| >> >> event of a CommandButton on a UserForm. Neither method cleared the
| >> >> Immediate
| >> >> window.
| >> >>
| >> >> Rick
| >> >>
| >> >>
| >> >> | >> >> > Yes it worked fine
| >> >> >
| >> >> > "Rick Rothstein (MVP - VB)" wrote:
| >> >> >
| >> >> >> Did that code work for you? All that happens for me is the date
and
| >> >> >> time
| >> >> >> are
| >> >> >> printed in the Immediate window... nothing is cleared.
| >> >> >>
| >> >> >> Rick
| >> >> >>
| >> >> >>
| >> >> >> | >> >> >> > very nice i never thought of sendkeys
| >> >> >> >
| >> >> >> > "Anant Basant" wrote:
| >> >> >> >
| >> >> >> >> try the following code.
| >> >> >> >>
| >> >> >> >> Sub DelInImmedate()
| >> >> >> >> Debug.Print Now
| >> >> >> >> Application.SendKeys "^g ^a {DEL}"
| >> >> >> >> End Sub
| >> >> >> >> --
| >> >> >> >> Regards,
| >> >> >> >> Anant
| >> >> >> >>
| >> >> >> >>
| >> >> >> >> "Madiya" wrote:
| >> >> >> >>
| >> >> >> >> > I am using some debug.print statements in my code which
prints
| >> >> >> >> > current
| >> >> >> >> > value of my variables in the immediate window.
| >> >> >> >> > When I run the code again, I have to manually select all and
| >> >> >> >> > delete
| >> >> >> >> > the values from the immediate window.
| >> >> >> >> >
| >> >> >> >> > Is there any way by which I can just run the code to clear
the
| >> >> >> >> > immediate window?
| >> >> >> >> >
| >> >> >> >> > Thanks and Regards,
| >> >> >> >> > Madiya
| >> >> >> >> >
| >> >> >>
| >> >> >>
| >> >>
| >> >>
| >
| > --
| >
| > Dave Peterson
|
 
R

Rick Rothstein \(MVP - VB\)

Thanks for the reply. I have it ask me whether to enable macros or not at
start up.. that should be protection enough, so I'll leave the option
checked.

Rick
 
B

Bob Phillips

You need to set a reference to the Extensibility library.

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
R

Rick Rothstein \(MVP - VB\)

As it turns out, this answer...

Tools|Macro|Security|Trusted Publishers tab
Check "Trust access to Visual Basic Project"

which I got in the other sub-thread allowed the subroutine to work.

Thanks for posting the code, by the way... like others, I figured it was not
possible to clear the Immediate window via code. Pretty neat.

Rick
 
B

Bob Phillips

I know, I goofed!

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
M

Madiya

You need to set a reference to the Extensibility library.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

message



- Show quoted text -

Its great !!!!!!!!!!!!!!!!!!!!!
I thought that I have a very simple problem.
I was watching curiously. There's a lot to learn when great minds are
at work.

Bob,
It works for me perfectly without setting any referance to the
Extensibility library.
Is this referance required anyway?

Regards,
Madiya
 
P

Peter T

If I follow how it all works, the PostMessage API places various keystorkes
in the 'queue' which'll only get processed when the code completes. Hence
your B's get printed before all is deleeted deleted.

I assume this is also why the "restore keyboard state" is done with an
Ontime macro, in particular to reset Ctrl & Shift (ctrtl-shift-home
backspace).

Regards,
Peter T
 
B

Bob Phillips

Madiya,

No as I said to Rick, that was me goofing up. You just need to set Trust
Access To Visual Basic Project

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



You need to set a reference to the Extensibility library.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

message



- Show quoted text -

Its great !!!!!!!!!!!!!!!!!!!!!
I thought that I have a very simple problem.
I was watching curiously. There's a lot to learn when great minds are
at work.

Bob,
It works for me perfectly without setting any referance to the
Extensibility library.
Is this referance required anyway?

Regards,
Madiya
 
P

Peter T

The security setting Check "Trust access to Visual Basic Project" needs to
be checked due to this line -

sMain = Application.VBE.MainWindow.Caption

I'm pretty sure it'd be possible to get the handle of the Immediate Window
(ultimate objective) via other means, which would avoid the concern over
that setting. Although maybe it's also required for other stuff, I'd need to
look more, eg the docking.

Regards,
Peter T
 
P

Peter T

Just curiosity, have you or anyone actually ever received a malicious virus
in an Excel xls/a.

A couple of years ago I searched the big name antivirus sites and the only
mention I could find was documented last century, I think a file for XL95

Regards,
Peter T

"Jim Rech"
 
J

Jim Rech

Sorry for not scrolling done this far, Peter<g>. Nope, I have never
personally received a file with a virus attached. I had someone send me one
he got years ago just so I could look it over As you say it seems so....
twentieth century. First Word and then Outlook were much more popular, as I
recall. But even those seem to have faded away.

--
Jim
| Just curiosity, have you or anyone actually ever received a malicious
virus
| in an Excel xls/a.
|
| A couple of years ago I searched the big name antivirus sites and the only
| mention I could find was documented last century, I think a file for XL95
|
| Regards,
| Peter T
|
| "Jim Rech"
| > Back in the day when "macro viruses" were all the rage they sometimes
| > propagated programming the VBE itself. I think the misanthropes have
| mostly
| > moved to the web so not a great deal to worry about, and you can always
| > disable all macros when opening a workbook.
| >
| > --
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top