Join The Works program to have access to the most current content, and to be able to ask questions and get answers from Revelation staff and the Revelation community

At 25 MAR 2010 10:22:04PM Colin Rule wrote:

I have some code which I can open a spreadsheet and populate it with data, but this feeds the first worksheet.

I need to be able to select the specified worksheet.

ObjExcel=OLECreateInstance("Excel.Application")

ObjWorkBooks=OleGetProperty(ObjExcel,"WorkBooks")

ObjSheet=OleCallMethod(ObjWorkBooks,"Open",ExcelFileName)

ObjWork =OleCallMethod(ObjSheet,"Select",ExcelWorksheet)

Variable 'ExcelWorksheet' contains my worksheet name.

This is failing to select it.

I assume I am on the wrong track somewhere.

Any ideas on how to select a worksheet.

Thanks

Colin


At 26 MAR 2010 12:08AM Warren Auyong wrote:

The easiest way I've found how to figure out steps like this is to record a macro of the things you want to do and then edit the macro.

All the methods and properties you need get exposed in this manner.


At 28 MAR 2010 07:34PM Colin Rule wrote:

I have tried this, but it does not give me enough information to determine how to do this in OI.

Any other ideas?

Colin


At 29 MAR 2010 06:21PM Bob Carten wrote:

Hi Colin

I think you want call the select method on a range object

oXl=OleCreateInstance('Excel.Application')

oWkbks=oXl-]WorkBooks

oSheet=oWkbks-]Open(filename)

oXl-]Visible=-1

address=$':A:'$':12

this_range=OleGetProperty(oXl, 'Range',address)

x=this_Range-]Select()


At 29 MAR 2010 08:03PM Colin Rule wrote:

Bob

Thanks, but I cant see where the Worksheet name is within this example.

The select applies to a cell range.

I need to be able to select a worksheet, eg Sheet2

Thanks

Colin


At 30 MAR 2010 03:52AM Warren Auyong wrote:

Google "select worksheet by name"

Sheet Navigation

View this thread on the Works forum...

  • third_party_content/community/commentary/forums_works/88b7f07bcb6fb704852576f2000d01c7.txt
  • Last modified: 2023/12/30 11:57
  • by 127.0.0.1