View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
John Green[_3_] John Green[_3_] is offline
external usenet poster
 
Posts: 49
Default Selection method not available in VB when referencing Excel worksheet

ActiveSheet is not a property of the workbook object but of the application object, which is why your code fails.

Selection is tricky. It is a property of the Application or the Window object. If you already have an object variable referring to
the Excel application, use:

FirstRow = myExcelApp.Selection.Row

--

John Green - Excel MVP
Sydney
Australia


"Oscar" wrote in message . nl...

Bob,

I can adress activeworksheet after activeworkbook, but the VB IDE doesn't
show any members such as the selection method after the dot after
'activesheet' method. In case that I write it by hand I receive an error
during runtime.

So I can't have myExcelApp.Activeworkbook.Activesheet.Selection.ro w
interpreted by the compiler.
Oscar




"Bob Phillips" schreef in bericht
...
Oscar,

Selection can only apply to the activesheet of the activeworkbook, so this
gets the first selected row

selection.row

and this is the last

selection.rows.count+selection.row-1

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Oscar" wrote in message
.nl...
In a VB application, I am referencing an Excel workbook. I need to know

the
row number of the toprow and bottomrow of any range selection. Therefore

I
want to use the selection object. However, the 'selection' object is not
available for the Excel.worksheet method and is only available for the
Excel.application and it doesn't show any method after selection. For
example I can't use selection.rows. How can I change this ?

Oscar