Hello,
I am using a batch file to call some dxl that was given to me. The dxl takes an argument (in this case the module path) to export a word document of that module. See below:
{code}
// override some default message box functions, so they will only print the data but
// not pause execution. Write to a log file here!
bool confirm (string s) { print "Confirmed: " s "\n"; return true }
void ack (string s) {print "Acknowledge: " s "\n" }
void acknowledge (string s) {print "Acknowledge: " s "\n" }
void infobox (string s) {print "Info: " s "\n" }
void info (string s) {print "Info: " s "\n" }
DB theDiag = null
// Now override block and show, to only do realize
void show (DB x) { realize x; theDiag = x }
void block (DB x) { realize x; theDiag = x }
if (null current Module) {
print "You need to have a current Module set for the export."
halt
}
// we need braces, since -D will be executed at top level and we will get name
// clashes for variable defined in word.dxl and the other includes of it.
{
// now include the word.dxl -> this will pop up the dialog, but not halt execution
// due to the overrides above
#include <standard/export/office/word.dxl>
// here we can change the dialog options. See itfui2.inc and word.dxl for all
// the options
set(exportHeadingsToggle, false) // turn off export of headings
set(exportLayoutChoice,layoutTypeTable)
//string fname = "c:/adi.doc"
//set(exportFileName,fname)
// now manually launch the export button callback
doExport theDiag
// get rid of the dialog
if (!null theDiag) destroy theDiag
// close DOORS
exit_
}
{/code} This works great.... except, it doesn't save. I wrote a vbscript to capture the active document and save it (but vbscript does not believe that a document is active). After some googling, I found posts on this site, which claim it can be saved using dxl and ole handles (my modules do not contain ole objects).
This is the code that I found. I pasted this right before the exit line in my export_batch.dxl code (from Mathias Mamsch) https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014568900#77777777-0000-0000-0000-000014568065 {code}
OleAutoObj wDocs = null, wDoc = null
OleAutoObj wApp = oleGetAutoObject "Word.Application"
olePut (wApp, "visible", "true")
oleGet(wApp, "Documents", wDocs)
OleAutoArgs args = create()
oleMethod (wDocs, "Add", args, wDoc)
put (args, "C:\\tmp\\Test.docx") // choose a meaningful file path
print "SaveAs:" oleMethod (wDoc, "SaveAs", args)
{/code} This saves a word document named "test" in the temp folder... however the document is blank, and the doors export is open, and named Document2.doc.
Is there a way to save the doors export document? Did I paste the code above in the wrong spot? I would really appreciate help if anyone understands this better.
Thanks bmic - Tue Jan 07 16:24:19 EST 2014 |
Re: Automating DOORS Export to Word and saving document Well one problem that you are having is that you are adding a new document with this code: oleGet(wApp, "Documents", wDocs) OleAutoArgs args = create() oleMethod (wDocs, "Add", args, wDoc) which you are saving. That is the reason why it is empty. Instead you can try to use the "ActiveDocument" to get a handle to the exported document. You may want to take a closer look at the code, just trial and error is a hard way to get to your goal. If you have problems understanding any code, feel free to ask. Regards, Mathias |
Re: Automating DOORS Export to Word and saving document Mathias Mamsch - Wed Jan 08 03:51:50 EST 2014 Well one problem that you are having is that you are adding a new document with this code: oleGet(wApp, "Documents", wDocs) OleAutoArgs args = create() oleMethod (wDocs, "Add", args, wDoc) which you are saving. That is the reason why it is empty. Instead you can try to use the "ActiveDocument" to get a handle to the exported document. You may want to take a closer look at the code, just trial and error is a hard way to get to your goal. If you have problems understanding any code, feel free to ask. Regards, Mathias Perhaps:
|
Re: Automating DOORS Export to Word and saving document I'm trying to export a number of modules within a folder to word, automatically. The code above has helped quite a bit in producing a script that worked very well in windows XP, thank you bmic. Since recently upgrading to windows 7, the export no longer works as it used it. The word file used to save, but now does not. A prompt in MS Word open up prompting me (the user) to save the file. In the meantime, the next module opens, and DOORS generates an error message that reads: "CRCRD5311W: OLE method failed: Problem with OLE Argument names. Do you want to continue? [buttons: Yes/Yes to all/No/Details>>]" If I click "Yes", DOORS generates the error message: "CRCRD5422E: Unable to get inline shapes collection. [buttons: OK / Details]". If I click "OK", it opens the next module and generates the same sequence of error messages. Any guidance or advice? Here is a sample of the code:
string exportCode (string sFullName) {
string sExportCode =
current = mod
v=view(\"Book 101\")
return sExportCode
void processFolder(Folder f)
} |
Re: Automating DOORS Export to Word and saving document Mathias Mamsch - Wed Jan 08 03:51:50 EST 2014 Well one problem that you are having is that you are adding a new document with this code: oleGet(wApp, "Documents", wDocs) OleAutoArgs args = create() oleMethod (wDocs, "Add", args, wDoc) which you are saving. That is the reason why it is empty. Instead you can try to use the "ActiveDocument" to get a handle to the exported document. You may want to take a closer look at the code, just trial and error is a hard way to get to your goal. If you have problems understanding any code, feel free to ask. Regards, Mathias Hi Mathias
The line: oleMethod (wDocs, "Add", args, wDoc) Here you can use: oleMethod (wDoc, "Save", args)
Best regards |
Re: Automating DOORS Export to Word and saving document llandale - Wed Jan 08 11:39:00 EST 2014 Perhaps:
Hi Louie You mustn't use ActiveDocument, because this is not the active document in any circumstances. Best regards Wolfgang |
Re: Automating DOORS Export to Word and saving document Are you wanting a new document for every Module you export to MS Word with it's own name? |
Re: Automating DOORS Export to Word and saving document woodpryan - Thu Jun 25 11:47:09 EDT 2015 Are you wanting a new document for every Module you export to MS Word with it's own name? Yes, exactly that |
Re: Automating DOORS Export to Word and saving document Daniel_M__ - Thu Jun 25 14:30:23 EDT 2015 Yes, exactly that Well, I think you've really boxed yourself in here by using Word.dxl. That was not written to be used this way. It wasn't written to be used in any way other than its original intention, which is simply bad design. If you're willing to let go of Word.dxl, I can provide you with some functions that you can use to complete your task. The Word.dxl export function does some things that you should simply not be doing in a loop like this. Stop me if these are not the requirements of this task 1. Loop through every Module recursively within the currently selected Folder 2. For each Module create a new MS Word document 3. For each Object in the Module output the DOORS Number, Heading and Object Text to the Word document. 4. Save the Word document using the name of the Module. 5. Close MS Word when all Modules within the selected Folder have been exported.
Do you need the progress bar that is created by Word.dxl? When does this task need to be completed? |
Re: Automating DOORS Export to Word and saving document woodpryan - Thu Jun 25 17:25:14 EDT 2015 Well, I think you've really boxed yourself in here by using Word.dxl. That was not written to be used this way. It wasn't written to be used in any way other than its original intention, which is simply bad design. If you're willing to let go of Word.dxl, I can provide you with some functions that you can use to complete your task. The Word.dxl export function does some things that you should simply not be doing in a loop like this. Stop me if these are not the requirements of this task 1. Loop through every Module recursively within the currently selected Folder 2. For each Module create a new MS Word document 3. For each Object in the Module output the DOORS Number, Heading and Object Text to the Word document. 4. Save the Word document using the name of the Module. 5. Close MS Word when all Modules within the selected Folder have been exported.
Do you need the progress bar that is created by Word.dxl? When does this task need to be completed? I had thought that maybe 1 or 2 lines need be corrected and not have to approach this issue with a completely new solution...though I am very open to new approaches and suggestions.
I can say that your list would be the requirements as I see them as well, though please add to that that OLE objects must be kept, so it is not just 'text' as indicated in #3 of your list. The progress bar is not essential. There is no strict deadline, though would be nice to have the task complete within the next week or so. Thanks very much for your gracious offer to help. |
Re: Automating DOORS Export to Word and saving document Well, I've actually already written every function you need, from opening MS Word to adding a new document, saving a document, closing it, writing text and graphics, etc. It's just a matter of copying the necessary functions into a file on their own and calling them in the right order. I have to do this while I am on my own time as well, so I will try to get it for you by Monday. What I post here should be more easily usable and more easily added to than the Word.dxl garbage IBM provided. |
Re: Automating DOORS Export to Word and saving document So, this code is un-tested and I will not be surprised if you have a few problems at first. If you can figure out how to work through them, great. Otherwise, let me know what you run into and I will fix the issue. The code is attached to this reply. Attachments TempCode.dxl |
Re: Automating DOORS Export to Word and saving document woodpryan - Fri Jun 26 19:30:42 EDT 2015 So, this code is un-tested and I will not be surprised if you have a few problems at first. If you can figure out how to work through them, great. Otherwise, let me know what you run into and I will fix the issue. The code is attached to this reply. Thanks very much for your sample code. I was able to get it working to a point where I could get the object heading and object text to export. Unfortunately, the pictures are not being exported, any thoughts on why? |
Re: Automating DOORS Export to Word and saving document The call to VBA's "AddPicture" method is surrounded in a call to vbaCheckRes, which prints any errors in an acknowledgment window. Did you get any errors in a window? Tell me about your pictures. Are they JPEGs or what? Any other information you can give me will help me debug the issue.
So, is this thing creating new documents for each Module? Is it saving each document when it finishes? Does it close each document after it is generated? |
Re: Automating DOORS Export to Word and saving document woodpryan - Wed Jul 01 11:40:21 EDT 2015 The call to VBA's "AddPicture" method is surrounded in a call to vbaCheckRes, which prints any errors in an acknowledgment window. Did you get any errors in a window? Tell me about your pictures. Are they JPEGs or what? Any other information you can give me will help me debug the issue.
So, is this thing creating new documents for each Module? Is it saving each document when it finishes? Does it close each document after it is generated? No error messages popped up, though, admittedly, I had to add a few lines and remove a few lines of code here and there to get the script to run, so I'm not sure if I removed anything that is vital to getting the OLE objects to export. The updated code is attached. I should have written OLE objects instead of pictures, as some are visio drawings, embedded excel files, etc.
The script creates a single word file and appends each module to it, so to create 1 massive word file.
In the meantime, I was able to get the script that I had posted above to work, by modifying a section of the code to read as follows:
...
olePut (wApp, \"visible\", \"true\")
OleAutoArgs args = create()
put (args, \"d:\\\\" sFullName "\") oleCloseAutoObject(wDoc)"
return sExportCode Attachments tempCode.dxl |
Re: Automating DOORS Export to Word and saving document Daniel_M__ - Fri Jul 03 13:57:43 EDT 2015 No error messages popped up, though, admittedly, I had to add a few lines and remove a few lines of code here and there to get the script to run, so I'm not sure if I removed anything that is vital to getting the OLE objects to export. The updated code is attached. I should have written OLE objects instead of pictures, as some are visio drawings, embedded excel files, etc.
The script creates a single word file and appends each module to it, so to create 1 massive word file.
In the meantime, I was able to get the script that I had posted above to work, by modifying a section of the code to read as follows:
...
olePut (wApp, \"visible\", \"true\")
OleAutoArgs args = create()
put (args, \"d:\\\\" sFullName "\") oleCloseAutoObject(wDoc)"
return sExportCode Sorry, man. If I had had some time to do some testing I would have found a number of issues with that code. I did do some testing this time. Got it all fixed up. It's exporting my figures just fine, but mine are actually JPG images. I don't know about your figures, but either way try this, and let me know how it goes. It will now create, save, and close a new document for each Module in the folder. The code is attached. Attachments TempCode.dxl |
Re: Automating DOORS Export to Word and saving document woodpryan - Mon Jul 06 12:51:28 EDT 2015 Sorry, man. If I had had some time to do some testing I would have found a number of issues with that code. I did do some testing this time. Got it all fixed up. It's exporting my figures just fine, but mine are actually JPG images. I don't know about your figures, but either way try this, and let me know how it goes. It will now create, save, and close a new document for each Module in the folder. The code is attached. Thanks very much for the help. I ran into a couple error messages running your attached script, though I haven't had a chance to look into them just yet. I'll try and have a look at it again at some point.
Error messages:
-E- DXL: <Line:648> incorrect arguments for function (olePut) |
Re: Automating DOORS Export to Word and saving document Oh. Sorry. You're just missing a few definitions from ole.inc that I have added. Add these lines to the top of TempCode.dxl: const int wdAlignParagraphCenter = 1; const string cPropertyAlignment = "Alignment";
You should be good to go. |