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: Include file to get OLE/COM easier
Topic Summary: Some usefull stuff to work with VBA
Created On: 26-Jul-2006 07:56
Status: Post and Reply
Linear : Threading : Single : Branch
1 2 Next Last unread
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 Reik Schroeder, on Monday, July 14, 2008 12:24 PM

Answer:
Hi Simon,

you are right, I've updated the file already, but did not posted here, sorry.

Please try the attached one - it should work better

Greetings
Reik Schröder
 26-Jul-2006 07:56
User is offline View Users Profile Print this message


Reik Schroeder

Posts: 361
Joined: 28-Jul-2003

Hi @all,

as I've seen, there are often problems concerning VBA/OLE/COM and Doors.
So I want to help you a little bit and share my very simple, but powerfull include file with you

It will allow you to use a dot instead of complicate calls to oleGet or oleMethod.

I hope you will enjoy it ...

Greetings
Reik Schroeder

OLE_COM.inc
OLE_COM.inc  (3 KB)



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


Berlin, Germany
Report this to a Moderator Report this to a Moderator
 26-Jul-2006 17:02
User is offline View Users Profile Print this message


Shawn Stepper

Posts: 96
Joined: 6-Aug-2004

Very cool! Thanks for posting Reik!

Shawn

-------------------------
Shawn Stepper
shawn.e.stepper@wellsfargo.com
Report this to a Moderator Report this to a Moderator
 26-Jul-2006 19:02
User is offline View Users Profile Print this message


Chris Jones

Posts: 177
Joined: 1-Jul-2005

Are you serious?????

That is completely awesome Reik! It will make my life so much easier.....especially since my next big project requires a lot of OLE interaction with Word.

I've been playing with it and it's great. Thank you!

Chris
Report this to a Moderator Report this to a Moderator
 28-Jul-2006 13:33
User is offline View Users Profile Print this message


Thomas Langholz

Posts: 40
Joined: 20-Oct-2005

wow reik, what a great idea of overloading the dot-expression
that would have helped me great but now im almost finish with my word-project

thanx for that nice file
Report this to a Moderator Report this to a Moderator
 4-Aug-2006 10:19
User is offline View Users Profile Print this message


Andrew Tagg

Posts: 151
Joined: 26-Oct-2004

Superb, will file under "why didn't I think of this?"

-------------------------
Andrew Tagg
Thales Air Systems, Melbourne
Australia.
andrew.tagg@thalesatm.com
Report this to a Moderator Report this to a Moderator
 15-Aug-2006 11:10
User is offline View Users Profile Print this message


Dirk Plaschke

Posts: 103
Joined: 17-Sep-2002

Is there a any way to put a (or more) parameter to a call, like

OleAutoObj objOutlook = newOle(cObjOutlookApplication)
objOutlook.sendMail(sendTo,subject,...) // <-- this, I mean

or objOutlook.sendMail("my.name@company.com")

or objOutlook.To("my.name@company.com") / i.e.
objOutlook.Subject("SUBJECT")
objOutlook.Body("BODY")
objOutlook.Display

instead of calling a procedure ("sendMail( objOutlook, sendTo, subject, ...)")?

-------------------------
Dirk Plaschke
Report this to a Moderator Report this to a Moderator
 15-Aug-2006 11:29
User is offline View Users Profile Print this message


Reik Schroeder

Posts: 361
Joined: 28-Jul-2003

Hi Dirk,

of course it possible to have such functions, but it is a little bit more complicated. You need to store the method name and the parameters into a special parameter block

please attached example, how it could be done ...
I did not used OLE automation for Outlook until now, so I do not know exactly how to send a mail, please refer to VBA manual or to Tony's posting in this forum
Sending eMails with Outlook

Greetings to Treptow
Reik

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


Berlin, Germany
Report this to a Moderator Report this to a Moderator
 15-Aug-2006 14:02
User is offline View Users Profile Print this message


Dirk Plaschke

Posts: 103
Joined: 17-Sep-2002

Hi, Reik.

Thanks for your knowledge ;-)
... but DOORS rejects a call like objOutlook.subject("Sorry, no mail!")
DOORS prefers a objOutlook.(subject("Sorry, no mail!"))
(notice the '(' before 'subject...'

The error message is:

-E- DXL: <\oleOutlook.lib:287> incorrect arguments for (.)
and
-E- DXL: <\oleOutlook.lib:287> incorrectly concatenated tokens

Did you know a fix for that?

PS: It#s sort of weird, to comuunicate via Britain from Berlin to Berlin, isn't it?

-------------------------
Dirk Plaschke
Report this to a Moderator Report this to a Moderator
 16-Aug-2006 09:05
User is offline View Users Profile Print this message


Reik Schroeder

Posts: 361
Joined: 28-Jul-2003

Hi Dirk,

sorry, you might be right ... this idea of implementing oleMethod call was in my mind for a long time, but did not checked, if it really works ...
Now I tried it for some MS Word functions and come to the same result. It seems to be a problem of interpretation of code from left to right.

For now I've no suggestion, how to solve this problem - but I think it looks much better than the original
checkRes(oleMethod .... stuff

Greetings
Reik

P.S.: The Server of this site seems to be in Sweden, so the communication from Berlin to Berlin is done via Sweden

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


Berlin, Germany
Report this to a Moderator Report this to a Moderator
 16-Aug-2006 09:51
User is offline View Users Profile Print this message


Reik Schroeder

Posts: 361
Joined: 28-Jul-2003

Hi @all,

here is a new version the include file, which allows now to assign oleProperties in a "nice" syntax:

obj."Property" = value;

Another new idea is to allow the creation of oleMethods, but unfortunately it works not as supposed. (:
You need to add some more parenthis to get it work.
A call to example CreateItem method would like this :

OleAutoObj msg = outlook.(createItem (0));

assuming that outlook helds an MS Outlook appliaction object.

Greetings
Reik

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


Berlin, Germany

Edited: 16-Aug-2006 at 12:31 by Reik Schroeder
Report this to a Moderator Report this to a Moderator
 10-May-2007 14:24
User is offline View Users Profile Print this message


Andrew Tagg

Posts: 151
Joined: 26-Oct-2004

This should definately be included as standard with DOORS. Always wondered why telelogic made such a meal of the OLE syntax?

-------------------------
Andrew Tagg
Thales Air Systems, Melbourne
Australia.
andrew.tagg@thalesatm.com
Report this to a Moderator Report this to a Moderator
 10-May-2007 17:36
User is offline View Users Profile Print this message


David Pechacek

Posts: 674
Joined: 5-Dec-2006

Awesome Reik.

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

Edited: 10-May-2007 at 17:41 by David Pechacek
Report this to a Moderator Report this to a Moderator
 11-May-2007 08:18
User is offline View Users Profile Print this message


Reik Schroeder

Posts: 361
Joined: 28-Jul-2003

Thank you, I'm really supprised that you like this idea

Now I have an addon.
I have extracted all the constants form MS Office applications using the oleview.exe tool from
Windows Server 2003 Resource Kit Tools

You will find them attached including perl script to convert the IDL file into these constant files.

Greetings
Reik




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


Berlin, Germany

Edited: 14-May-2007 at 05:32 by Reik Schroeder
Report this to a Moderator Report this to a Moderator
 14-May-2007 00:54
User is offline View Users Profile Print this message


Paul Miller

Posts: 376
Joined: 2-Oct-2002

Hi,

Is anyone else having problems downloading Reik's PERL script file? When I try to download it I get a "Page Not Found" error. Are you able to re-post Reik?

-------------------------
Paul Miller
Specification Practices Specialist,
EuroCyber,
Melbourne, Australia.
Mobile: +61 (0)418 135 103
Web Site: http://www.eurocyber.biz
E-mail: miller@eurocyber.biz">pmiller@eurocyber.biz
Report this to a Moderator Report this to a Moderator
 14-May-2007 05:34
User is offline View Users Profile Print this message


Reik Schroeder

Posts: 361
Joined: 28-Jul-2003

Hi Paul,
it seems to be a real problem of the forum server to handle .pl files ....
The only way to place the code here was to zip it

So i've changed the original post to contain the perl script in a zip file .

Greetings
Reik

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


Berlin, Germany
Report this to a Moderator Report this to a Moderator
 17-Jan-2008 14:45
User is offline View Users Profile Print this message


Simon Morrish

Posts: 127
Joined: 17-May-2005

Hi Reik

Thanks for making OLE usable!

I can get property values, but not set them. For instance, the following code doesn't work:


#include <utils/ole.inc>
#include <../inc/OLE_COM/OLE_COM.inc>
#include <../inc/OLE_COM/oleWordConstants.inc>

OleAutoObj objWord = initializeOLEapplication(cObjWordApplication)
OleAutoObj objFind = objWord."ActiveDocument"."Content"."Find"
objFind."Forward" = true


I get the checkRes() error message. I looked at your clever OLE_COM.inc to try to work out why, but don't understand the following:


...
OleAutoObj ::= (olePropertyLHS p, _x val) { // implementation of olePut
...


What is "_x"? (If I change this to "bool" the code works fine, but obviously for booleans only!)

Any help appreciated...

regards,
Simon

PS. I'm using DOORS 8.3.

-------------------------
Simon Morrish
simon.morrish@eu.panasonic.com
http://panasonic.co.uk
Panasonic ideas for life
Report this to a Moderator Report this to a Moderator
 21-Jan-2008 06:20
User is offline View Users Profile Print this message


Uma Unnikrishnan

Posts: 32
Joined: 7-Aug-2006

This is coool. I was just starting to work with word and am sure this would make my job easier.
thanx for sharing it with us.
Report this to a Moderator Report this to a Moderator
 21-Jan-2008 06:20
User is offline View Users Profile Print this message


Uma Unnikrishnan

Posts: 32
Joined: 7-Aug-2006

This is coool. I was just starting to work with word and am sure this would make my job easier.
thanx for sharing it with us.
Report this to a Moderator Report this to a Moderator
 22-Feb-2008 11:17
User is offline View Users Profile Print this message


Reik Schroeder

Posts: 361
Joined: 28-Jul-2003

Hi Simon,

sory for my late answer, but I hevn't much time to look into forum the last weeks .. month

You cannot cascade the syntax I've implemented.
That means your code should look like this:

//#include <utils/ole.inc>
#include <../inc/OLE_COM/OLE_COM.inc>
#include <../inc/OLE_COM/oleWordConstants.inc>

OleAutoObj objWord = initializeOLEapplication(cObjWordApplication)
OleAutoObj objAD = objWord."ActiveDocument";
OleAutoObj objContent = objAD."Content";
OleAutoObj objFind = objContent."Find"
objFind."Forward" = true

closeIfNonNull (objFind);
closeIfNonNull (objContent);
closeIfNonNull (objAD);
closeIfNonNull (objWord);

The close functions are really needed! There is a limit on number of open Ole handles and they will not be closed automatically.
It can happen, if you have left an open OLE handle, that the target application can not be closed correctly.

Hope that helps you,
Greetings
Reik

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


Berlin, Germany
Report this to a Moderator Report this to a Moderator
 27-Feb-2008 17:49
User is offline View Users Profile Print this message


Simon Morrish

Posts: 127
Joined: 17-May-2005

Hi Reik

Thanks very much for your reply. I should have explained my problem better though. Sorry! Let me try again:

The line that fails in my example is:

objFind."Forward" = true

and I find it still fails in your code above. I get the "OLE method failed" error from checkRes().

The error is coming from your implementation of olePut, but I'm not sure if I'm using it incorrectly or if it's a bug. Can you run your code above successfully? (I tried it from the DOORS Edit DXL window, with Word already open.)

Also, please could you tell me what "_x" means in the following?:

OleAutoObj ::= (olePropertyLHS p, _x val) { // implementation of olePut

I can't find it in the documentation, so I assume it's one of those undocumented DXL features??

Many thanks in advance for any help you can offer...
best regards,
Simon

-------------------------
Simon Morrish
simon.morrish@eu.panasonic.com
http://panasonic.co.uk
Panasonic ideas for life
Report this to a Moderator Report this to a Moderator
Telelogic DOORS » DXL Exchange » Include file to get OLE/COM easier

1 2 Next Last unread
Topic Tools Topic Tools
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 1 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 1 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.