DoCommand("Copy") - SelectAll

In IDE Scripting, there is a command called DoCommand which will execute a number of commands. One of these is Copy. So the line of the IDE Script is

DoCommand("Copy")

If you run an IDE Script that contains this line of code, one of two things will happen

  1. If there is no text highlighted in the Code Window, then the entire code of the Code Window will be copied to the clipboard

  2. If there is some text highlighted, then only the highlighted part of the text of the Code Window will be copied to the clipboard.

In my situation, I want only the behavior (1) to occur in my IDE Script. I could accomplish this in two ways that I can think of. One would be to “unhighlight” all the text in the Code Window (which you can do manually just by clicking somewhere in the Code Window) or I could select all the text (highlight it) before issuing the

DoCommand("Copy")

But I cannot figure out how to do this within an IDE Script (i.e. issue some command to make sure that nothing is highlighted before the DoCommand(“Copy”) command or alternatively issue some command to make all the code in the Code Window highlighted before the DoCommand(“Copy”).

Is there some way to do this? Is there some code that you can put in an IDE Script that accomplishes this goal?

Actually highlighting all the text before

DoCommand("Copy")

is not optimal for my purposes.

If no text is highlighted, then the Clipboard gets all the text in the window but also an initial line

Sub printCrossSection(which As Integer)

and a terminating line

End Sub

These lines are not put on the Clipboard if all the text is highlighted before the

DoCommand("Copy").

So, for my purposes, what I want is to find a command in IDE Scripting that will “unhighlight” any text that might be highlighted before the line of code.

DoCommand("Copy").

I have stumbled across the answer to the question. Text is a special thing that refers to the entire content of a Code Window.

If there is text highlighted in your Code Window when you run an IDE Script, the following line will act to unselect it.

Text = Text

In general, if you assign Text anything, then any characters that might be highlighted are unselected. The SetText of IDE Scripting is set to nothing.

Using Text = Text is a way of doing this when you do not actually want to change the content. When you just want to get rid of the highlighting.