Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic DOORS (steve huntington)
Decrease font size
Increase font size
Topic Title: Excel Sheet Change
Topic Summary:
Created On: 26-Jun-2007 19:08
Status: Post and Reply
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Quick Reply Quick Reply
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
Answer This question was answered by David Pechacek, on Wednesday, June 27, 2007 2:06 PM

Answer:
Here is a way to get the sheet by sheet number. However, be aware that the second sheet in a workbook may not necessarily correspond to the sheet number 2. If there are macros there can be things called modules (don't ask me what these are exactly) which exist in the Sheets collection. So be sure to check that the name of the sheet does not contain the word "Module".

You must first get a handle to the workbook.
 26-Jun-2007 19:08
User is offline View Users Profile Print this message


Brian Rohler

Posts: 26
Joined: 20-Jun-2007

When writing to an excel file from doors, I currently am only able to get the active sheet using
CheckRes(OleGet(ObjWorkbook, cPropertyActiveSheet, objSheet))
-This stores the active sheet as objSheet and gets it from the objWorkbook (both OleAutoObjs)
-cPropertyActiveSheet is an included constant string "ActiveSheet"
My question is what do I subsitute instead of "cPropertyActiveSheet" in order to get "Sheet2" of the workbook?

Report this to a Moderator Report this to a Moderator
 26-Jun-2007 19:23
User is offline View Users Profile Print this message


David Pechacek

Posts: 674
Joined: 5-Dec-2006

Answer Answer
Here is a way to get the sheet by sheet number. However, be aware that the second sheet in a workbook may not necessarily correspond to the sheet number 2. If there are macros there can be things called modules (don't ask me what these are exactly) which exist in the Sheets collection. So be sure to check that the name of the sheet does not contain the word "Module".

You must first get a handle to the workbook.

-------------------------
David Pechacek
AAI Services Textron
dpechacek@sc-aaicorp.com
David.Pechacek@gmail.com
Report this to a Moderator Report this to a Moderator
 27-Jun-2007 13:58
User is offline View Users Profile Print this message


Brian Rohler

Posts: 26
Joined: 20-Jun-2007

quote:

Originally posted by: David Pechacek
Here is a way to get the sheet by sheet number. However, be aware that the second sheet in a workbook may not necessarily correspond to the sheet number 2. If there are macros there can be things called modules (don't ask me what these are exactly) which exist in the Sheets collection. So be sure to check that the name of the sheet does not contain the word "Module". You must first get a handle to the workbook.


What is the value of the constants cPropertySheets and cMethodActivate?
Report this to a Moderator Report this to a Moderator
 27-Jun-2007 14:01
User is offline View Users Profile Print this message


David Pechacek

Posts: 674
Joined: 5-Dec-2006

"Sheets" and "Activate"

Do a search for my Excel functions post. It includes an ole.inc file with all the ones that comes in the DOORS ole.inc file plus many others I have added.

Those two are in the DOORS ole.inc file though. Just do:

#include <utils/ole.inc>

-------------------------
David Pechacek
AAI Services Textron
dpechacek@sc-aaicorp.com
David.Pechacek@gmail.com

Edited: 27-Jun-2007 at 14:04 by David Pechacek
Report this to a Moderator Report this to a Moderator
 27-Jun-2007 14:06
User is offline View Users Profile Print this message


Brian Rohler

Posts: 26
Joined: 20-Jun-2007

Yeah i just figured out what they were, although my ole.inc doesn't contain those two (perhaps its an old version). Thanks for the help! Much appreciated.
Report this to a Moderator Report this to a Moderator
 27-Jun-2007 14:17
User is offline View Users Profile Print this message


David Pechacek

Posts: 674
Joined: 5-Dec-2006

OK maybe I added those two.

-------------------------
David Pechacek
AAI Services Textron
dpechacek@sc-aaicorp.com
David.Pechacek@gmail.com
Report this to a Moderator Report this to a Moderator
 28-Jun-2007 12:58
User is offline View Users Profile Print this message


Andrew Tagg

Posts: 151
Joined: 26-Oct-2004

Thanks David, did me a favour too. I played around with this to work out how to delete a sheet also. Dont have the code right here, but I can post it tomorrow if its not already in your archive.

-------------------------
Andrew Tagg
Thales Air Systems, Melbourne
Australia.
andrew.tagg@thalesatm.com
Report this to a Moderator Report this to a Moderator
 28-Jun-2007 13:29
User is offline View Users Profile Print this message


David Pechacek

Posts: 674
Joined: 5-Dec-2006

Actually I don't have a function written to delete a sheet. Its not something I do but I wouldn't mind having it.

-------------------------
David Pechacek
AAI Services Textron
dpechacek@sc-aaicorp.com
David.Pechacek@gmail.com
Report this to a Moderator Report this to a Moderator
 2-Jul-2007 08:56
User is offline View Users Profile Print this message


Andrew Tagg

Posts: 151
Joined: 26-Oct-2004

My main reason for writing the delete sheet function was to get rid of the 3 default sheets that are present when you create a new workbook. That way only my new named sheets are present in the end file.

Note that this is best done at the end, as excel does not like it if you have a workbook with NO worksheets.

In the included code I have passed the name of the sheet to be deleted as a string, but you could also pass the sheet number as an integer, as shown in the get sheet example above, it works well both ways.

-------------------------
Andrew Tagg
Thales Air Systems, Melbourne
Australia.
andrew.tagg@thalesatm.com
Report this to a Moderator Report this to a Moderator
 2-Jul-2007 19:06
User is offline View Users Profile Print this message


David Pechacek

Posts: 674
Joined: 5-Dec-2006

You could always just rename the sheets automatically created by Excel.

-------------------------
David Pechacek
AAI Services Textron
dpechacek@sc-aaicorp.com
David.Pechacek@gmail.com
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 2 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 16:36.
There are currently 0 guests browsing this forum, which makes a total of 2 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.