Page 1 of 1 1
Topic Options
#197539 - 2010-01-26 11:51 AM Activate worksheet in Excel
Peter_fleur Offline
Just in Town

Registered: 2005-04-30
Posts: 1
Loc: Netherlands
Hi All,

I'm struggeling with an easy question but i cannot find the answer. I want to read some data from an Excel sheet with multiple worksheets. Normally the sheet is saved on a different worksheet then the worksheet i need with my script. So when i open the file i need to activate the other sheet.
To open the file is use:
$exsheet = $workshare+"\klanten.xlsx"
$objexcel = CreateObject("Excel.Application")
$oke = $objexcel.workbooks.Open ($exsheet)

I tried to use: $objexcel.workbooks.Activate("Places")
but that does not work.

Does anybody know a good method for activating the correct worksheet?

Thanks!!!

Peter

Top
#197540 - 2010-01-26 11:57 AM Re: Activate worksheet in Excel [Re: Peter_fleur]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
Welcome to KORG!

There is a set of dedicated UDFs for manipulating Excel objects that should make things easier. The large library is called "XlLib". The functions include
 Code:
;;	xlInit()		Create the Excel object reference
;;	xlQuit()		Destroy the instantiated object & shut down Excel
;;	xlFile()		Open, Save, or SaveAs file functions
;;	xlBookCreate()		Create a new workbook in the active object
;;	xlBookProperties()	Read / Set the workbook properties
;;
;;	xlSheetAdd()		Create a new worksheet, define properties
;;	xlSheetName()		Read / Set the active worksheet name
;;	xlSheetSelect()		Set the active worksheet by name or index #
;;	xlSheetDelete()		Delete the specified sheet
;;	xlSheetPrint()		Prints the specified sheet
;;	xlSheetCount()	   (EK)	Returns the number of sheets in the workbook
;;
;;	xlRangeValue()		Read / Write a worksheet cell or range
;;	xlRangeClear()		Clear the specified worksheet range
;;	xlRangeDelete()		Delete the specified worksheet range
;;	xlRangeFormat()		Read / Set style formatting attributes on a cell range
;;	xlRangeFormatNum() (EK)	Read / Set number formatting attributes on a cell range
;;	xlRangeFreeze()		Set / Unset display pane freezing at a specific cell
;;	xlRangePrint()		Prints the specified worksheet range
;;	xlRangeSearch()	   (EK)	Searches a range for a value
;;	xlRangeSort()	   (EK)	Sorts the specified range
;;
;;	xlPageSetup()		Read / Set global format and printing options
;;	xlWindow()		Read / Set the Excel application window visibility status
;;
;; The following are utility functions to aid in the manipulation of Excel settings
;;	xlCol()			Translate between alpha and numeric column IDs
;;	xlColRow()		Splits a cell reference (A1) into component reference parts (A, 1)
;;	xlColor()		Translates between color names and index values
;;
;; The functions marked "(EK)" were originally developed by Erik Kaerholm and adapted
;; to this library by Glenn Barnas. Erik's original library can be found at
;; http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=86576
You want to look at "xlSheetSelect()" in particular. They are posted here in the UDF forum, and maintained in the resources / Kix UDF Lib on my web site.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.055 seconds in which 0.029 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org