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: OLE Excel Workbook with Workbooks(Index)
Topic Summary: How to get a certain workbook from a Workbooks collection ?
Created On: 12-Oct-2007 14:47
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.
 12-Oct-2007 14:47
User is offline View Users Profile Print this message


Daniel Kübert

Posts: 10
Joined: 27-Sep-2007

Hi all,

I don´t get it. I want to get a certain workbook Object from Excel out of a Workbooks Collection by  Index of the Workbooks.

myWorkbook = Workbooks(1)

I tried lot of compinations .... but it won´t work :-(




Report this to a Moderator Report this to a Moderator
 12-Oct-2007 15:41
User is offline View Users Profile Print this message


Kevin Murphy

Posts: 206
Joined: 15-Jul-2005

Daniel,

There is no actual property called "Index". You need to refer to things by name, if possible.

If you know you'll have a workbook "Book1" and a workbook "Book2", use that. If you don't know, open Excel, create a workbook, save it to a known path, then create another and save it to a known path. Close both. Then open both by filename.

This way your code knows exactly what it's doing.

Good luck.

-------------------------
Kevin Murphy
http://www.baselinesinc.com
The Requirements Management Experts
Report this to a Moderator Report this to a Moderator
 12-Oct-2007 16:27
User is offline View Users Profile Print this message


Daniel Kübert

Posts: 10
Joined: 27-Sep-2007

Hi Kevin,

I think it is a common problem. I want to do the same with a sheets collection to get a sheet by Index.

for example in VBA:

Dim mySheets As Sheets
Dim mySheet As Worksheet

Set mySheets = ThisWorkbook.Sheets
Set mySheet = mySheets(1) //index 1 for sheet one



Report this to a Moderator Report this to a Moderator
 12-Oct-2007 20:07
User is offline View Users Profile Print this message


David Pechacek

Posts: 674
Joined: 5-Dec-2006

Here you go Daniel. I would assume getting a workbook from the workbooks collection is similar. Rewrite to fit your needs.

Also see my previous post of all the Excel functions I have. Also I believe someone else recently posted one.

-------------------------
David Pechacek
AAI Services Textron
dpechacek@sc-aaicorp.com
David.Pechacek@gmail.com
Report this to a Moderator Report this to a Moderator
 15-Oct-2007 11:25
User is offline View Users Profile Print this message


Reik Schroeder

Posts: 361
Joined: 28-Jul-2003

Hi Daniel,

the attached code will help you to solve your problem
It will allow you to use the following syntax:
objWorkbooks[2]
to access second element from workbooks (or any other) collection in objWorkbooks.

Be carefull, MS uses sometimes Item as method and sometimes as property depending on collection type. Please refer to VBA documentation of the desired collection object for details.

Greetings
Reik

-------------------------
Evosoft GmbH
for Siemens Industry Sector


Berlin, Germany
Report this to a Moderator Report this to a Moderator
 16-Oct-2007 14:04
User is offline View Users Profile Print this message


Daniel Kübert

Posts: 10
Joined: 27-Sep-2007

Thanks both of you. It works fine.
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.