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 Function Call
Topic Summary: How to call a simple function in Excel with OLE ?
Created On: 17-Oct-2007 10:02
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.
 17-Oct-2007 10:02
User is offline View Users Profile Print this message


Daniel Kübert

Posts: 10
Joined: 27-Sep-2007

Hi,

I´m trying to call a simple VBA function IsNumeric ?

But it is a simple function with (with return value bool) and no Object ? I don´t get a clue how to do that.

I want to write an import from an Excel Cell. If there is a cell with standard Format and a Number is in the Cell, the string import doesn´t work. :-( . So I think I´ve to check the Cell first if it IsNumer(objCell) = True and then return an Interger instead. After that I can cast the Integer to a string.

THX.

 
Report this to a Moderator Report this to a Moderator
 17-Oct-2007 14:01
User is offline View Users Profile Print this message


Dennis Lockshine

Posts: 113
Joined: 7-Apr-2003

Daniel,

Instead of using the "Value" property of the Range object to get the contents of the cell, use the "Text" property as shown in my modification of your code. There is no need to check to see if the cell is numeric or not.

-Dennis
Report this to a Moderator Report this to a Moderator
 17-Oct-2007 14:08
User is offline View Users Profile Print this message


Kevin Murphy

Posts: 206
Joined: 15-Jul-2005

This is just off the top of my head as I don't have time to fool around with code. So take my answer with a grain of salt.

Your VBA function, IsNumeric, returns true or false. The problem is that you need to communicate that to DOORS. I don't believe you can call a function and get the result from DOORS, but could be very, very wrong about that.

You should make your function called from a Sub in VBA. The VBA code would look like:

Function IsNumeric(C as Range)
'code here
end function

Sub callIsNumeric(C as Range)
call IsNumeric(C)
End sub

Then you want IsNumeric to actually fill a value in a cell, something like Sheet2, Cell A1. Call the Macro from DXL and then read the value from Sheet 2, Cell A1.

Another idea is creating your own custom class with a property and using OLE to get that property.

Perhaps someone more versed in DXL OLE Automation can be of more help, but I wanted to give you some ideas in case not.

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


David Pechacek

Posts: 674
Joined: 5-Dec-2006

I have a working Import from Excel script but unfortunately my company does not allow me to share it since it was developed with Air Force money so the Air Force technically owns it. I am trying to get it out to everyone here but unfortunately we're going through a buyout right now so the lawyers are busy.

What I can tell you is that yes you should use the Text value of a Cell. This is because for whatever reason, the value property of a Cell is not always set and can return a null which isn't good. Now, the downside of this is that the Text property truncates text at 1024 characters. To get around this, what I do in my script is that if the text is over 1000 characters, I pull the Value property and check that the text I got from the Text property matches the Value property. If not, I use the Value property data. However all this is only done assuming I am importing rich text (an option in my script) since it essentially involves a copy and paste which DOORS can truncate on when copying from Excel (even manually).

I looked a lot at the DOORS import from a spreadsheet since I was basically trying to mirror functionality plus add to it. I have many of the same error messages and what not that theirs does. From it though you can get how to handle values that you get and what to do with them. Like what to do with an Integer, a Real, etc. If you need any other help writing your Importer let me know.

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


Daniel Kübert

Posts: 10
Joined: 27-Sep-2007

Lol, thx. Sometimes the solutions are so easy :-)

Out of my own interest, do you know how to call a VBA function ?

I think about the VBA  shell() Function and so on.
Thanks David for your hint with the characters i´will have a look at the Spreadsheet script.

The support in this forum is really good.

Edited: 17-Oct-2007 at 15:02 by Daniel Kübert
Report this to a Moderator Report this to a Moderator
 17-Oct-2007 15:15
User is offline View Users Profile Print this message


Kevin Murphy

Posts: 206
Joined: 15-Jul-2005

Daniel,

When you ask how to call a VBA function, do you mean in VBA or how to run a macro in DXL?

-------------------------
Kevin Murphy
http://www.baselinesinc.com
The Requirements Management Experts
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.