Can Someone please write me a DXL function that does this:
I figure to select an Object that needs the Word table; select the Word table and run the code; then paste it into the Object. -Louie llandale - Tue Jan 08 16:21:18 EST 2013 |
Re: Make Embedded Word Object function. Why not just create a new document paste to that copy and then close without saving? Is it better to just write it in VBA since DOORS is not involved at all? Adam |
Re: Make Embedded Word Object function. SystemAdmin - Wed Jan 09 03:01:10 EST 2013 |
Re: Make Embedded Word Object function. SystemAdmin - Wed Jan 09 07:40:13 EST 2013 So Louie for you that means you will not get a reliable connection to an open word instance. Period. If the user has another word opened, before he opens you two word instances, you will not get any handle to the OLEs. However the question here would be if you do know the filenames of the files, so you can open one or two word instances yourself and load the data in there? Or why is it so important to use already opened word files? Regards, Mathias Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS |
Re: Make Embedded Word Object function.
I have no idea what I'm doing.
When I use variable g_objDocsSrce at that line I get:
There seems to be a lot of "OleAutoObj" variables and I'm probably using the wrong one. //#include <Includes\Lib-Incs_Level-2.inc> //#include <Utils\ole.inc> string g_NameSourceFile = "c:/Doors-Stuff/Reports/ReportsRaw/Attrs_Report-Types-Folder_NVR-2010_2013-Jan-11_000.rtf" OleAutoObj g_objDocsTemp = null, g_objDocsSrce = null DB db //*************************************************************** OleAutoObj fWord_OpenFileNew() { // Create a new MS-Word instance and open a "New" file OleAutoObj objWordTemp, objDocsTemp, objOptsTemp OleAutoArgs AutoArgs string ErrMess objWordTemp = oleCreateAutoObject("Word.Application") // Open Temp File olePut (objWordTemp, "Visible", true) oleGet (objWordTemp, "Documents", objDocsTemp) // Failed: "New", FileNew, ErrMess = oleMethod (objDocsTemp, "Add")//, AutoArgs) print ErrMess oleGet(objWordTemp, "Options", objOptsTemp) if (!null objOptsTemp) { olePut(objOptsTemp, "CheckSpellingAsYouType", false) olePut(objOptsTemp, "CheckGrammarAsYouType", false) } oleCloseAutoObject(objWordTemp) return(objDocsTemp) } // end fWord_OpenFileNew() // Open Source File //*************************************************************** OleAutoObj fWord_OpenFileGet() { // Get a handle on the currently open MS-Word file. There should be just one open. OleAutoObj objWordTemp, objDocsTemp, objOptsTemp OleAutoArgs AutoArgs string ErrMess objWordTemp = oleCreateAutoObject("Word.Application") oleGet (objWordTemp, "Documents", objDocsTemp) oleCloseAutoObject(objWordTemp) return(objDocsTemp) } // end fWord_OpenFileGet() //*************************************************************** void clbkOpenFiles(DBE dbeXX) { g_objDocsSrce = fWord_OpenFileGet() g_objDocsTemp = fWord_OpenFileNew() print (null g_objDocsTemp) "\t" (null g_objDocsSrce) "\n" } // end clbkOpenFiles() //*************************************************************** void clbkCopyPaste(DBE dbeXX) { OleAutoObj objSelected OleAutoArgs AutoArgs = create() clear(AutoArgs) string ErrMess oleGet(g_objDocsSrce,"Selection",objSelected) print "Copy: " oleMethod(objSelected, "Copy") //, AutoArgs) "\n" print "Paste: " oleMethod(objSelected, "Paste") //, AutoArgs) "\n" delete(AutoArgs) } //*************************************************************** void BuildDialog() { db = create("OLE Word Test") // button(db, "OpenFiles", clbkOpenFiles) button(db, "CopyPaste", clbkCopyPaste) realize(db) clbkOpenFiles(null DBE) show(db) } // end BuildDialog() BuildDialog() |
Re: Make Embedded Word Object function. llandale - Fri Jan 11 14:18:35 EST 2013
I have no idea what I'm doing.
When I use variable g_objDocsSrce at that line I get:
There seems to be a lot of "OleAutoObj" variables and I'm probably using the wrong one. //#include <Includes\Lib-Incs_Level-2.inc> //#include <Utils\ole.inc> string g_NameSourceFile = "c:/Doors-Stuff/Reports/ReportsRaw/Attrs_Report-Types-Folder_NVR-2010_2013-Jan-11_000.rtf" OleAutoObj g_objDocsTemp = null, g_objDocsSrce = null DB db //*************************************************************** OleAutoObj fWord_OpenFileNew() { // Create a new MS-Word instance and open a "New" file OleAutoObj objWordTemp, objDocsTemp, objOptsTemp OleAutoArgs AutoArgs string ErrMess objWordTemp = oleCreateAutoObject("Word.Application") // Open Temp File olePut (objWordTemp, "Visible", true) oleGet (objWordTemp, "Documents", objDocsTemp) // Failed: "New", FileNew, ErrMess = oleMethod (objDocsTemp, "Add")//, AutoArgs) print ErrMess oleGet(objWordTemp, "Options", objOptsTemp) if (!null objOptsTemp) { olePut(objOptsTemp, "CheckSpellingAsYouType", false) olePut(objOptsTemp, "CheckGrammarAsYouType", false) } oleCloseAutoObject(objWordTemp) return(objDocsTemp) } // end fWord_OpenFileNew() // Open Source File //*************************************************************** OleAutoObj fWord_OpenFileGet() { // Get a handle on the currently open MS-Word file. There should be just one open. OleAutoObj objWordTemp, objDocsTemp, objOptsTemp OleAutoArgs AutoArgs string ErrMess objWordTemp = oleCreateAutoObject("Word.Application") oleGet (objWordTemp, "Documents", objDocsTemp) oleCloseAutoObject(objWordTemp) return(objDocsTemp) } // end fWord_OpenFileGet() //*************************************************************** void clbkOpenFiles(DBE dbeXX) { g_objDocsSrce = fWord_OpenFileGet() g_objDocsTemp = fWord_OpenFileNew() print (null g_objDocsTemp) "\t" (null g_objDocsSrce) "\n" } // end clbkOpenFiles() //*************************************************************** void clbkCopyPaste(DBE dbeXX) { OleAutoObj objSelected OleAutoArgs AutoArgs = create() clear(AutoArgs) string ErrMess oleGet(g_objDocsSrce,"Selection",objSelected) print "Copy: " oleMethod(objSelected, "Copy") //, AutoArgs) "\n" print "Paste: " oleMethod(objSelected, "Paste") //, AutoArgs) "\n" delete(AutoArgs) } //*************************************************************** void BuildDialog() { db = create("OLE Word Test") // button(db, "OpenFiles", clbkOpenFiles) button(db, "CopyPaste", clbkCopyPaste) realize(db) clbkOpenFiles(null DBE) show(db) } // end BuildDialog() BuildDialog()
If I put oleCheck before all oleGet, oleMethod calls, void oleCheck (string s) { if (!null s) error s } I get
-R-E- DXL: <Line:8> Problem with OLE Argument names. Backtrace: <Line:67> // oleGet(g_objDocsSrce,"Selection",objSelected) <Line:84>
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: Make Embedded Word Object function. Mathias Mamsch - Fri Jan 11 15:52:32 EST 2013
If I put oleCheck before all oleGet, oleMethod calls, void oleCheck (string s) { if (!null s) error s } I get
-R-E- DXL: <Line:8> Problem with OLE Argument names. Backtrace: <Line:67> // oleGet(g_objDocsSrce,"Selection",objSelected) <Line:84>
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
-Louie |
Re: Make Embedded Word Object function. llandale - Mon Jan 14 12:49:09 EST 2013 You must not use "activeDocument" because that is an object you only have inside of Excel. Start with Excel.Application, then get "Documents" and then Document. Best regards Wolfgang |
Re: Make Embedded Word Object function. SystemAdmin - Tue Jan 15 03:05:08 EST 2013 In Word you have the Word Object Modell Overviev (http://msdn.microsoft.com/en-us/library/kw65a0we(v=vs.80).aspx). Do not use Application-Selection, because selection can be changed by a mouse click of the user. In a stable script you shall use Application-Document(s). |
Re: Make Embedded Word Object function. SystemAdmin - Tue Jan 15 03:05:08 EST 2013 I am now stuck on getting the current "Selection" of the original Document; "problem with ole argument names" when doing this:
|
Re: Make Embedded Word Object function. llandale - Tue Jan 15 10:43:18 EST 2013
In my code I get the selection from the Word object, not from the Document... Alain |
Re: Make Embedded Word Object function. adevicq - Tue Jan 15 12:11:38 EST 2013
Hello Louie OleAutoObj oleCompareApplication = null; // Object to hold a word reference ... OleAutoObj oleCompareApplicationDocuments = null; // Reference to the Documents object ... bool bApplicationCreated = false; // Marker (false = Word is not availiable on this PC)
/**************************************************************/ /** Module Initialisation ... ***************************************************************/ void InitUnit() { string sWordApp = "Word.Application"; bApplicationCreated = false; // If Word is runnig get an object reference ... oleCompareApplication = oleGetAutoObject(sWordApp); if (oleCompareApplication == null) { // Otherwise start word but do not make it visible (it is faster) oleCompareApplication = oleCreateAutoObject(sWordApp); bApplicationCreated = true; } if (oleCompareApplication == null) { // User does not have a word installation. // some error code? } else { oleCompareArguments = create; oleGet(oleCompareApplication, "Documents", oleCompareApplicationDocuments); } }
|
Re: Make Embedded Word Object function. llandale - Tue Jan 15 10:43:18 EST 2013
The 'Selection' object is related to the Word GUI. So you can only get the selection of the 'ActiveDocument' because only the 'ActiveDocument' has anything selected. Sure, you can get the 'Selection' from many Objects, but it will always return the selection of the 'ActiveDocument' even if called from a different document object. // Application.Selection oleGet(objApplication, "Selection", objSelection)
If you want the selection on a specific document, you must first make it the 'ActiveDocument'.
// Document.Activate oleMethod(objDocument, "Activate")
|
Re: Make Embedded Word Object function. SystemAdmin - Wed Jan 16 06:06:08 EST 2013
The 'Selection' object is related to the Word GUI. So you can only get the selection of the 'ActiveDocument' because only the 'ActiveDocument' has anything selected. Sure, you can get the 'Selection' from many Objects, but it will always return the selection of the 'ActiveDocument' even if called from a different document object. // Application.Selection oleGet(objApplication, "Selection", objSelection)
If you want the selection on a specific document, you must first make it the 'ActiveDocument'.
// Document.Activate oleMethod(objDocument, "Activate")
[http://msdn.microsoft.com/en-us/library/bb244515(v=office.12).aspx] It appears I need to keep track of several such Objects; unless there is some way to go back up the chain, Selection->Document->Documents->Application. -Louie |
Re: Make Embedded Word Object function. llandale - Fri Jan 18 13:57:43 EST 2013 Yes, you do ... > unless there is some way to go back up the chain, Selection->Document->Documents->Application. You can use "Parent" but a) I do not recommend this, I cannot say anything about this method b) The number you objects you have to track is the same. c) In the internet you finde examples in the top down direction not in the other. |
Re: Make Embedded Word Object function. I have been able to open the word document and make it visible using the following: Dim myWDoc As Variant Dim filename As String filename = "c:\\RCATest.docx" ' just for test purposes right now, later i will uses whatever they have attached.... Set myWDoc = GetObject(filename,"Word.Document") myWDoc.Application.Visible = True But I don't want to make the document visible, I just want to read it in (using script) and parse it out like any text file. Is this possible? If yes, can someone point me to the calls I would need to read in the data from the word document? Thanks for any input. |