UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Application.selection....what All Can You Do With It?, Any Version    
 
   
ipisors12
post Apr 2 2020, 04:57 PM
Post#1



Posts: 20
Joined: 14-March 19



This page, https://docs.microsoft.com/en-us/office/vba...ation.selection, suggests that Selection is a property. However, it seems to me more like an object with its own properties and methods.

Certainly "Selection.Clear" sounds like an object with a method, or something like that.

Semantics aside, where can I see all of what can be done with a Selection? usually MS docs are really good at showing a treeview on the left with properties, methods, members, but maybe I am on the wrong page/site?
Go to the top of the page
 
ADezii
post Apr 2 2020, 06:02 PM
Post#2



Posts: 2,996
Joined: 4-February 07
From: USA, Florida, Delray Beach


AFAIK, the best way to explain it, using Excel as an example is that:
Selection is a Property that returns the currently selected Object on the Active Worksheet for an Excel Application Object. If a single Cell is selected in a Worksheet, then Selection.Clear applied, you are executing the Clear Method of the Range Object. In the example that follows, Selection actually represents a Range Object.
CODE
Range("A25").Select

Debug.Print "The Selected Object is Type: " & TypeName(Selection)

CODE
The Selected Object is Type: Range

This post has been edited by ADezii: Apr 2 2020, 06:02 PM
Go to the top of the page
 
vtd
post Apr 2 2020, 07:22 PM
Post#3


Retired Moderator
Posts: 19,777
Joined: 14-July 05
From: Sydney NSW Australia


>>Certainly "Selection.Clear" sounds like an object with a method, or something like that.<<

It is a Property of the (Excel) Application Object which results in (i.e. gives you) an Object you can use in code. The resultant Object can be Nothing (if nothing is selected) or usually a Range Object. Note: a single Cell selection is still a Range Object with only 1 Cell in the Range.

>>Semantics aside, where can I see all of what can be done with a Selection?<<

If the Selection results in a Range Object, then you can use all the Properties & Methods of the Range Object which you can find in the Object Browser. Note that in the example you posted:

Selection.Clear

, the Clear Method is a Method of the Range Object.
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    31st May 2020 - 12:09 PM