Hi,
I have a number of modules with documents saved within as OLE objects. I'm trying to write a DXL script that will parse through all the objects in a module, cut the OLE objects (saving them to the clipboard) and then paste the object into a folder on the hard drive.
I know how to cut the OLE object (see code below, from the DXL Reference manual) but I don't know how to retrieve the object from the clipboard and save it to a folder.
Any suggestions?
Agustine
/*
this code segment checks whether the current formal object
contains an OLE object in its object text, and if it so, cuts it to the
system clipboard, and then pastes it into the next formal
object in the current formal module
*/
Object obj = current
if (oleIsObject obj){
if (oleCut obj){
obj = next current
if (obj != null){
if (olePaste obj == false)
print "Problem trying to paste object\n"
}
} else {
print "Problem trying to cut object\n"
}
} else {
print "Does not contain an embedded object in its object text\n"
}
/*
this DXL script cuts the second OLE object that exists in
column 1 of the module display
*/
string s = oleCut(current Object, column 2, 0)
dasilvaa - Mon May 25 09:31:20 EDT 2009 |
|
Re: Clipboard and OLE Objects Ron_Lewis - Mon May 25 10:14:17 EDT 2009
You may find the problem is easier if you save the ole before the cut.
|
|
Re: Clipboard and OLE Objects dasilvaa - Mon May 25 10:50:16 EDT 2009 Ron_Lewis - Mon May 25 10:14:17 EDT 2009
You may find the problem is easier if you save the ole before the cut.
Save the OLE straight to the hard drive? I didn't know that was possible, how do I do that?
|
|
Re: Clipboard and OLE Objects Ron_Lewis - Tue May 26 07:53:26 EDT 2009 dasilvaa - Mon May 25 10:50:16 EDT 2009
Save the OLE straight to the hard drive? I didn't know that was possible, how do I do that?
One approach is as follows:
{code)
void checkExportPicture(Object o, string attributeName, string baseFileName)
{ EmbeddedOleObject ole
int i = 1
string errmess = null
RichText rtf
string s = richTextWithOle o.attributeName
i = 1
for rtf in s do
{ if (rtf.isOle)
{ ole = rtf.getEmbeddedOle
string filename = baseFileName "-rtfloop-" i ".png"
print "Exporting " filename "\n"
errmess = exportPicture(ole,filename , formatPNG)
if (!null errmess) print "ERROR: " errmess "\n"
i++
}
}
}
Object o = current
checkExportPicture(o, "Object Text", "C:\\temp\\")
{code)
|
|
Re: Clipboard and OLE Objects dasilvaa - Wed May 27 10:20:57 EDT 2009 Ron_Lewis - Tue May 26 07:53:26 EDT 2009
One approach is as follows:
{code)
void checkExportPicture(Object o, string attributeName, string baseFileName)
{ EmbeddedOleObject ole
int i = 1
string errmess = null
RichText rtf
string s = richTextWithOle o.attributeName
i = 1
for rtf in s do
{ if (rtf.isOle)
{ ole = rtf.getEmbeddedOle
string filename = baseFileName "-rtfloop-" i ".png"
print "Exporting " filename "\n"
errmess = exportPicture(ole,filename , formatPNG)
if (!null errmess) print "ERROR: " errmess "\n"
i++
}
}
}
Object o = current
checkExportPicture(o, "Object Text", "C:\\temp\\")
{code)
That works, but only if the OLE object is a picture. What I need to do is save embedded Word/Excel/PDF documents to the hard drive.
Is there an equivalent perm for formats other than PNG? I couldn't seem to find anything in the DXL Reference manual.
|
|
Re: Clipboard and OLE Objects Ron_Lewis - Wed May 27 10:37:37 EDT 2009 dasilvaa - Wed May 27 10:20:57 EDT 2009
That works, but only if the OLE object is a picture. What I need to do is save embedded Word/Excel/PDF documents to the hard drive.
Is there an equivalent perm for formats other than PNG? I couldn't seem to find anything in the DXL Reference manual.
Options are limited.
One option is to create a view with only object text showing -- filter on desired object and then export to either msword or rtf.
OLE then may be selected.
|
|
Re: Clipboard and OLE Objects Ron_Lewis - Wed May 27 10:54:29 EDT 2009 Ron_Lewis - Wed May 27 10:37:37 EDT 2009
Options are limited.
One option is to create a view with only object text showing -- filter on desired object and then export to either msword or rtf.
OLE then may be selected.
Ps. No claim is given that options listed are good options -- you will find when working in DOORS you do have to find workarounds to get job done.
|
|
Re: Clipboard and OLE Objects dasilvaa - Wed May 27 15:14:01 EDT 2009 Ron_Lewis - Wed May 27 10:37:37 EDT 2009
Options are limited.
One option is to create a view with only object text showing -- filter on desired object and then export to either msword or rtf.
OLE then may be selected.
Sorry, but I'm not sure I follow. I should export the OLE objects to Word or Wordpad? I'm not sure how that would help.
I've tried looking at Shell.Application, to see if I can get use that to access to Windows functions, but no luck.
Any other suggestions??
|
|
Re: Clipboard and OLE Objects SystemAdmin - Thu May 28 16:47:58 EDT 2009 dasilvaa - Wed May 27 15:14:01 EDT 2009
Sorry, but I'm not sure I follow. I should export the OLE objects to Word or Wordpad? I'm not sure how that would help.
I've tried looking at Shell.Application, to see if I can get use that to access to Windows functions, but no luck.
Any other suggestions??
OLE automation can be used to save the embedded OLE object into it's native format.
There are two techniques that I have used:
1) Activate the embedded Ole object and do a "Save As" operation. This works well--very fast and efficient and avoids use of the clipboard. Last time I checked (version 8.0), this only worked in non-batch mode.
2) Copy OLE to the clipboard in DOORS, activate a new instance of the host application, create a blank document, paste the object, and do a "Save As" operation. This technique works in batch mode.
For OLE objects that don't have a "native" file format (ie. like MS Word Equation Editor objects), you'd still have to use technique 2, pasting into something like Visio or Word to retain access to the underlying OLE properties.
|
|
Re: Clipboard and OLE Objects dasilvaa - Fri May 29 09:27:57 EDT 2009 SystemAdmin - Thu May 28 16:47:58 EDT 2009
OLE automation can be used to save the embedded OLE object into it's native format.
There are two techniques that I have used:
1) Activate the embedded Ole object and do a "Save As" operation. This works well--very fast and efficient and avoids use of the clipboard. Last time I checked (version 8.0), this only worked in non-batch mode.
2) Copy OLE to the clipboard in DOORS, activate a new instance of the host application, create a blank document, paste the object, and do a "Save As" operation. This technique works in batch mode.
For OLE objects that don't have a "native" file format (ie. like MS Word Equation Editor objects), you'd still have to use technique 2, pasting into something like Visio or Word to retain access to the underlying OLE properties.
For some reason, I totally missed oleActivate in the Reference manual. It's not a bad idea, but the tricky part is if there are different types of documents (Word, PDF etc.) it'll be difficult to script the SaveAs without first knowing which app the OLE object belongs to.
I did find another way, using the clipboard. Here's the code if anyone's interested.
/*
************************
This code cuts an OLE object from a specific column within the current object
and then pastes it in a specific folder on the local computer
************************
*/
OleAutoArgs args = create
string s = oleCut(current Object, column 2, 0)
OleAutoObj objShell = null
OleAutoObj objFolder = null
OleAutoObj objFSelf = null
objShell = oleCreateAutoObject("shell.Application")
string result = ""
put(args, "C:\\temp\\")
result = oleMethod(objShell, "NameSpace",args, objFolder)
if (result != "") then print "NameSpace failed: " result
if (null objFolder) then print "objFolder is null"
result = oleGet(objFolder, "Self", objFSelf)
if (result != "") then print "objFSelf failed: " result
if (null objFSelf) then print "objFSelf is null"
clear (args)
put(args, "Paste")
result = oleMethod(objFSelf, "InvokeVerb", args)
if (result != "") then print "InvokeVerb failed: " result
|
|
Re: Clipboard and OLE Objects pete.kowalski - Wed Aug 25 21:43:22 EDT 2010 SystemAdmin - Thu May 28 16:47:58 EDT 2009
OLE automation can be used to save the embedded OLE object into it's native format.
There are two techniques that I have used:
1) Activate the embedded Ole object and do a "Save As" operation. This works well--very fast and efficient and avoids use of the clipboard. Last time I checked (version 8.0), this only worked in non-batch mode.
2) Copy OLE to the clipboard in DOORS, activate a new instance of the host application, create a blank document, paste the object, and do a "Save As" operation. This technique works in batch mode.
For OLE objects that don't have a "native" file format (ie. like MS Word Equation Editor objects), you'd still have to use technique 2, pasting into something like Visio or Word to retain access to the underlying OLE properties.
How do you perform a "save as" of an unknown OLE object with DXL?
|
|
Re: Clipboard and OLE Objects pete.kowalski - Fri Sep 17 20:31:26 EDT 2010 pete.kowalski - Wed Aug 25 21:43:22 EDT 2010
How do you perform a "save as" of an unknown OLE object with DXL?
The only solution I came up with that could be overkill is open the given OLE object in that native application and do a save as within that application.
|
|