martmeister

How do I select a Worksheet in Excel

10 posts in this topic

I have looked under help and couldnt find the answer I was looking for. I know this is probably a really easy answer but I was needing to know how to select a worksheet in Excel if you have multiple worksheets. Thanks a lot

Share this post


Link to post
Share on other sites



Help file quote:

_ExcelSheetActivate

--------------------------------------------------------------------------------

Activate the specified sheet by string name or by number.

#Include <Excel.au3>

_ExcelSheetActivate($oExcel, $vSheet)

Parameters

$oExcel An Excel object opened by a preceding call to _ExcelBookOpen() or _ExcelBookNew()

$vSheet The sheet to activate, either by string name or by number

Return Value

Success: Returns 1

Failure: Returns 0 and sets @error on errors:

@error=1: Specified object does not exist

@error=2: Specified sheet number does not exist

@error=3: Specified sheet name does not exist

Read the help file - there is plenty about working with Excel workbooks.


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

Or you can use :

oExcel = ObjCreate("Excel.Application")
$oExcel.Visible = 1
$oExcel.WorkBooks.Open ("full path filename")
$oExcel.Sheets ("sheet name" ).Select

Share this post


Link to post
Share on other sites

#4 ·  Posted

Is there a new way based on the current UDF?

Share this post


Link to post
Share on other sites

#5 ·  Posted

You can find the difference between the "old" and "new/current" version of the Excel UDF in th help file.

Function _ExcelSheetActivate has been removed. You specify the sheet you want to process as parameter when calling a function.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#6 ·  Posted

Understood - shame,as i'm still having trouble with the function as per: 

 

Share this post


Link to post
Share on other sites

#7 ·  Posted

You can still select the sheet "by hand". 

$oWorkbook.Sheets(<number or name>).Activate

I will check your other thread as soon as I return from my business trip. 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#8 ·  Posted

arrr! wasn't aware of that trick.

Excellent - I will give that a go.

 

And when you can - no rush really! Enjoy your trip.

Share this post


Link to post
Share on other sites

#9 ·  Posted

I got it working with your suggestion.

thanks for your help!

Share this post


Link to post
Share on other sites

#10 ·  Posted

:) 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now