![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: Writing to different excel worksheets Topic Summary: Code currently writes to 2 different excel worbooks, but want it to write to different excel worksheets... Created On: 20-Dec-2007 19:31 Status: Post and Reply |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
I need help with this code. This code currently writes some data to 2 different excel workbooks. Opens one workbook writes data -> Opens second workbook writes data. I would like to write data in sheet 1, then write data in sheet 2, and keep writing some other data into other sheets (up to sheet 8). Sheets 3-8 will include some data that is filtered out. I would like to modify my existing code from writing to two different workbooks -> TO writing to different excel sheets. Here is my code, please help me resolve this issue. Thank you
Edited: 20-Dec-2007 at 19:36 by Raul Castellanos |
|
![]() |
|
![]() |
|
Here is code...
Edited: 8-Jan-2008 at 22:59 by Raul Castellanos |
|
![]() |
|
![]() |
|
Hi Raul,
Working with Excel is very different from an Office version to another. For instance, Telelogic examples only work with Excel 95. Which version do you use yourself ? Assuming you're working with Excel 2000, this may help you. This perm activates the sheet with the required name from the given workbook, and returns an handle on it: |
|
![]() |
|
![]() |
|
Eric I've used my Excel programs with Excel from Office 97, Office 2000, Office XP, and Office 2003. The COM interface for Excel has remained largely the same. There are a few things I do with Excel that aren't supported by Office 97 & 2000 but the majority of it as far as getting sheets and cells, setting text, changing color, etc. is all the same.
Now I've never gone back to Excel 95 (god who would still use that?). But Telelogic's examples hardly only work with it. I haven't tested with Office 2007 yet either but Microsoft is pretty good about maintaining backwards compatibility. Looking at the MSDN stuff, it looks to be the same with some extra features added in. The code you posted is similar to mine and it works with every version of Office I've tested with. ------------------------- David Pechacek AAI Services Textron dpechacek@sc-aaicorp.com David.Pechacek@gmail.com |
|
![]() |
|
![]() |
|
Raul. Here is an old post of mine with many useful Excel functions. It's a bit outdated but has what you need. I've only added a few minor things since then.
Excel functions Feel free to email me with any questions. ------------------------- David Pechacek AAI Services Textron dpechacek@sc-aaicorp.com David.Pechacek@gmail.com Edited: 21-Dec-2007 at 15:46 by David Pechacek |
|
![]() |
|
![]() |
|
I am using Office Excel 2003
|
|
![]() |
|
![]() |
|
I am running into some problems. I am able to open up another worksheet (sheet 4, since excel initalizes with 3 sheets) with this code, but it will not write to the sheet 4. I keep getting a OLE method failed, then it says "Unable to get active sheet".
I am confused on how to use the bool getSheet(int sheetNumber) function. I dont understand what to write in put(args, sheetNumber) ? Can you give me an example on how to use this function to write to Sheet 4-8? Edited: 8-Jan-2008 at 23:00 by Raul Castellanos |
|
![]() |
|
![]() |
|
You're basically using args to pass parameters to Excel functions. You want sheet 4. So you put 4 in the argument list. That's passed to the Item property of the Sheets collection and it assigns item 4 to the objSheet variable.
I think I know what the problem is though. As I said thats an old version. Add the statement "clear(args)" before the "put(args, sheetNumber)" statement. That will clear the arguments. ------------------------- David Pechacek AAI Services Textron dpechacek@sc-aaicorp.com David.Pechacek@gmail.com |
|
![]() |
|
![]() |
|
I added "clear(args)" before "put(args, sheetNumber)" statement and initialized "int sheetNumber = 4" and i think i ran into another problem.
this is what the code looks like. Now I get an error "Problem with OLE Argument names", so i think there is something wrong with my code. I have been looking at it for 2 days... Edited: 8-Jan-2008 at 23:00 by Raul Castellanos |
|
![]() |
|
![]() |
|
I just noticed something Raul in your nextSheet() method.
At line 68: checkRes(oleGet(objWorkbooks,cPropertyActiveSheet,objSheet)) This is incorrect. It needs to be: checkRes(oleGet(objWorkbook,cPropertyActiveSheet,objSheet)) That is probably the source of the error your mentioned. ------------------------- David Pechacek AAI Services Textron dpechacek@sc-aaicorp.com David.Pechacek@gmail.com Edited: 21-Dec-2007 at 21:23 by David Pechacek |
|
![]() |
|
![]() |
|
That did it...Thank you David. Thats the benefit of having someone else look at your code and it worked.
Thanks a bunch |
|
![]() |
|
![]() |
|
Now this fixes my problem of having to write to two different worksheets. My output data currently writes to Sheet 1 (first set of data) and then to Sheet 4 (second set of data). How would I apply a filter to my first set of data and output 5 more worksheets from different modules. I am thinking I have to do a loop to create 5 more new worksheets and then write to them separately the same way I did with sheet 4? Is that right?
|
|
![]() |
|
![]() |
|
Yes that sounds right. I assume you mean filter the DOORs data? This is very simple and explained in the DXL Reference manual.
Glad I could help. I'm outta here for the year. See all you DXLiens in 2008. ------------------------- David Pechacek AAI Services Textron dpechacek@sc-aaicorp.com David.Pechacek@gmail.com |
|
![]() |
Telelogic DOORS
» DXL Exchange
»
Writing to different excel worksheets
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.