How to activate an OLE, externally?

Hi,
I am trying to create a script which will check two different attributes to see if an OLE Excel object is present. If it is found I want to open the object in Excel, not in the embedded DOORS excel. I need this becaues DOORS9 Windows 7 when I double click on an object to view it it goes into embedded activation and I cannot see all of the excel columns. It is very easy to open a OLE object if it is in the Object Text attribute, oleOpen(o). But how do I open the OLE Excel Object if it is in a different attribute?

Object o = current
 
void openOLE(bool ProposedOLE)
{
  RichText rtf
  string s
  if (ProposedOLE)
     s = richTextWithOle o."Proposed_Object Text"     
  else
  {  
     oleOpen(o)  // I want this to work for any attribute I choose... how do I do this?
     return
  }
  OleAutoObj ObjExcel = oleCreateAutoObject("Excel.Application") // Open Excel
  bool excelVisible
  oleGet(ObjExcel, "Visible", excelVisible)
  if (excelVisible == false)
     olePut(ObjExcel, "Visible", true)
  for rtf in s do
  {
    if (rtf.isOle)
    {
      EmbeddedOleObject ole = rtf.getEmbeddedOle
      oleCopy(ole)  //??
      oleMethod(ObjExcel, "Paste") // ???
//      oleOpen(ole)
      break
    }
  } 
//  oleCloseAutoObject(ObjExcel)
}
 
openOLE(true)

SystemAdmin - Wed Feb 27 12:20:32 EST 2013

Re: How to activate an OLE, externally?
SystemAdmin - Wed Feb 27 18:12:46 EST 2013

This sounds strangely familiar. Check my thread http://www.ibm.com/developerworks/forums/thread.jspa?threadID=470409&tstart=0

I have Windows 7 and DOORS 9.3.0.5 and don't get the same issue. Double clicking the OLE will launch the Excel application. I don't know if this is some kind of configuration setting or not. Specifically, you have to click on the object to select the object, double click in the column where the OLE is to get into edit mode, click on the OLE to select it and then double click to launch the application.

Alternately, you can get the application to launch instead of an inline application by selecting the OLE and then in the menu select Edit->Worksheet Object->Open. If it is a word document it will say Document Object instead of Worksheet Object.

For worksheets, either the Edit or Open will launch the application. If it is a word document table, then Open will launch the word application, Edit will launch the inline application. At least in my configuration.

In any case, to activate the OLE through dxl you need to use the oleActivate command. oleActivate(obj) will activate the OLE in the object text. oleActivate(obj, column c, index) will activate it in other attributes when the column is the attribute you want. However, there are strange things happening here. I don't know what the oleOpen(o) command is that is in your code.

Trying to just launch the excel application and pasting the ole from the clipboard doesn't seem to work right either. Again, see my post for this topic.

Sorry I couldn't help you more.
Greg

Re: How to activate an OLE, externally?
SystemAdmin - Wed Feb 27 18:41:51 EST 2013

SystemAdmin - Wed Feb 27 18:12:46 EST 2013
This sounds strangely familiar. Check my thread http://www.ibm.com/developerworks/forums/thread.jspa?threadID=470409&tstart=0

I have Windows 7 and DOORS 9.3.0.5 and don't get the same issue. Double clicking the OLE will launch the Excel application. I don't know if this is some kind of configuration setting or not. Specifically, you have to click on the object to select the object, double click in the column where the OLE is to get into edit mode, click on the OLE to select it and then double click to launch the application.

Alternately, you can get the application to launch instead of an inline application by selecting the OLE and then in the menu select Edit->Worksheet Object->Open. If it is a word document it will say Document Object instead of Worksheet Object.

For worksheets, either the Edit or Open will launch the application. If it is a word document table, then Open will launch the word application, Edit will launch the inline application. At least in my configuration.

In any case, to activate the OLE through dxl you need to use the oleActivate command. oleActivate(obj) will activate the OLE in the object text. oleActivate(obj, column c, index) will activate it in other attributes when the column is the attribute you want. However, there are strange things happening here. I don't know what the oleOpen(o) command is that is in your code.

Trying to just launch the excel application and pasting the ole from the clipboard doesn't seem to work right either. Again, see my post for this topic.

Sorry I couldn't help you more.
Greg

Thank you for the info and help.

I can activate objects by:
1) Click on the object, but not double click, so it is highlighted
2) Edit->WorksheetObject->Open

This takes too long. I am looking for a fast alternative since my double clicking of the OLE Excel opens it in DOORS, not externally. I am creating a script which will become a Right Click on object and then give a new option to open it. From there I will display a dialog box to allow the user to either open the OLE Object Text or if there is a proposed change OLE Object open it. I have everything complete except for how do I activate a OLE which is not in the Object Text attribute.

I have read your forum posts before I posted my own. Where I am confused is how do I know what column matches the attribute? The DXL function takes in an integer. How can I line up column 3 is o."Proposed Change Stuff" vs o."Version Number"? What column is 1, 2, 3 in a particular module, view?

I believe this is one to two line change ... I just do not understand the oleActivate(..)

Thanks,
Zak

Re: How to activate an OLE, externally?
SystemAdmin - Wed Feb 27 20:02:43 EST 2013

SystemAdmin - Wed Feb 27 18:41:51 EST 2013
Thank you for the info and help.

I can activate objects by:
1) Click on the object, but not double click, so it is highlighted
2) Edit->WorksheetObject->Open

This takes too long. I am looking for a fast alternative since my double clicking of the OLE Excel opens it in DOORS, not externally. I am creating a script which will become a Right Click on object and then give a new option to open it. From there I will display a dialog box to allow the user to either open the OLE Object Text or if there is a proposed change OLE Object open it. I have everything complete except for how do I activate a OLE which is not in the Object Text attribute.

I have read your forum posts before I posted my own. Where I am confused is how do I know what column matches the attribute? The DXL function takes in an integer. How can I line up column 3 is o."Proposed Change Stuff" vs o."Version Number"? What column is 1, 2, 3 in a particular module, view?

I believe this is one to two line change ... I just do not understand the oleActivate(..)

Thanks,
Zak

I figured it out...

To open an OLE object in its own application, not inside DOORS use:
oleOpen(..)

If the object is not part of the Object Text you must:
1) figure out what Column the OLE is, you can use
Link:https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14455023&#14455023
2) Use the same parameters as oleActivate(Object, Column, Index)
 

oleActivate(o, c, 0)  // activates   the OLE in DOORS
oleOpen(o, c, 0)  // activates/opens the OLE in Excel   <-- solution!!!

 


Zak

 

Re: How to activate an OLE, externally?
SystemAdmin - Fri Mar 01 09:00:29 EST 2013

Good morning Zak,
Yes, I was also able to get oleOpen(o,c,0) to work for me, where oleActivate did not. How did you come about finding this command, as it is not listed in the dxl reference manual?

The routine I use to find the column for the attribute is as follows. I hope it helps you.
code
{
//Search for column of the attribute
bCol_Found = false
for c in curmod do {
if (main(c) && (sAttr == "Object Text" || sAttr == "Object Heading")) {
//main column is a combination of object text and object heading so it is special
bCol_Found = true
c1 = c //save column number
if (DEBUG) print "Found OLE in main column at OID: " identifier o1 "\n"
break //only look for the first column of the attribute, just in case they have two columns for the same attribute
}
else {
if (attrName(c) == sAttr) {
bCol_Found = true
c1 = c //save column number
if (DEBUG) print "Found OLE in column: " attrName(c1) " at OID: " identifier o1 "\n"
break //only look for the first column of the attribute, just in case they have two columns for the same attribute
}
}
}
}
Note that this is just the snippet, so it doesn't include the declarations, etc.

By the way, I found out that we work for the same company, just different locations!
Greg

Re: How to activate an OLE, externally?
SystemAdmin - Fri Mar 01 13:12:56 EST 2013

SystemAdmin - Fri Mar 01 09:00:29 EST 2013
Good morning Zak,
Yes, I was also able to get oleOpen(o,c,0) to work for me, where oleActivate did not. How did you come about finding this command, as it is not listed in the dxl reference manual?

The routine I use to find the column for the attribute is as follows. I hope it helps you.
code
{
//Search for column of the attribute
bCol_Found = false
for c in curmod do {
if (main(c) && (sAttr == "Object Text" || sAttr == "Object Heading")) {
//main column is a combination of object text and object heading so it is special
bCol_Found = true
c1 = c //save column number
if (DEBUG) print "Found OLE in main column at OID: " identifier o1 "\n"
break //only look for the first column of the attribute, just in case they have two columns for the same attribute
}
else {
if (attrName(c) == sAttr) {
bCol_Found = true
c1 = c //save column number
if (DEBUG) print "Found OLE in column: " attrName(c1) " at OID: " identifier o1 "\n"
break //only look for the first column of the attribute, just in case they have two columns for the same attribute
}
}
}
}
Note that this is just the snippet, so it doesn't include the declarations, etc.

By the way, I found out that we work for the same company, just different locations!
Greg

Greg,
The DXL Reference Manual list oleOpen(Object) only. I assumed since you can use the menus Edit... to open an OLE they must have a quick easy way to do it. The DOORs Menu has Edit and Open so I figured the edit is oleActivate(...) and the open was oleOpen(...). After being fed up with not finding a solution I just changed my oleActivate to oleOpen... going by pure guess work and logic. It worked :-p

My column lookup was very tiny and did not do a lot of error checking like the ones listed in the link from the above posts.

Column getColumn(string columnName)
{
   Column c
   int leng, offset; 
   string s;
   int i = 0;
   for c in m do
   {
      s = dxl(c);
      s = title c  // must use title or search returns nothing found
//      if (!null s) // if I do this it finds nothing
      if (findPlainText (s, columnName, leng, offset, false))            
         break
      i++
   }
   return column i;
}

 


I love this forum. I have learned soo much DXL and I attribute 85% to these forums.

Zak

 

Re: How to activate an OLE, externally?
cwicker - Wed Apr 08 11:07:05 EDT 2015

SystemAdmin - Wed Feb 27 20:02:43 EST 2013

I figured it out...

To open an OLE object in its own application, not inside DOORS use:
oleOpen(..)

If the object is not part of the Object Text you must:
1) figure out what Column the OLE is, you can use
Link:https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14455023&#14455023
2) Use the same parameters as oleActivate(Object, Column, Index)
 

oleActivate(o, c, 0)  // activates   the OLE in DOORS
oleOpen(o, c, 0)  // activates/opens the OLE in Excel   <-- solution!!!

 


Zak

 

I know this is an old discussion but, I have been trying to implement what was presented here and I have been getting an error.

"... doors.exe caused an EXCEPTION_ACCESS_VIOLATION in module doors.exe"

The error traces to the hasAttachment = oleOpen() call.

I have tried using the oleOpen and the oleActivate and both give me the same error.

I know the object is loaded correctly because I can load all the attributes properly. I have used print statements to confirm that the column title and number are correct for "ATTACHED_FILE".

Here is my code ...

Column getColumn(string columnName)
{
   Column c = null;
   Regexp findCol = regexp columnName;
   string s;
   int i = 0;   
   for c in mPR do 
   {
      s = title c ; 
      if (findCol s) return column i;
      i++;
   }
   return c;
}

void openAttachment(DBE inputForm) 
{
  string hasAttachment = "";
  Column c = getColumn("ATTACHED_FILE")
  if (null c) 
  {
    ack "Column not found";
    return;
  }
  hasAttachment = oleOpen(o, c, 0);
  if (hasAttachment == "") ack "No attachment found."; 
}

btOpenOle = button(inputForm, "Open Attachment", openAttachment)