GhostLine Posted May 17, 2013 Share Posted May 17, 2013 Hi ! I'm looking for a solution to "paste" a Word document's content into an Excel cell. I need that nor the Word file and Excel file appear on screen during the operation. Has anyone already done this ? Thanks ! Link to comment Share on other sites More sharing options...
water Posted May 17, 2013 Share Posted May 17, 2013 How large is the document? There are Copy and Paste methods in both the Word and Excel COM. But when pasting to Excel I fear the formatting will give you some headache. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
GhostLine Posted May 17, 2013 Author Share Posted May 17, 2013 (edited) Not so big ... it has roughly to fit on a quarter A4 page, in order to let some space to the other informations I put on the Excel file. Ultimately, the whole thing must be printable on a single A4 paper page. Edited May 17, 2013 by GhostLine Link to comment Share on other sites More sharing options...
water Posted May 17, 2013 Share Posted May 17, 2013 If you manually copy the Word document into the Excel cell are you happy with the formatting? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
GhostLine Posted May 17, 2013 Author Share Posted May 17, 2013 (edited) Yes sir I especially format the Word file to fit onto the Excel cell. Edited May 17, 2013 by GhostLine Link to comment Share on other sites More sharing options...
water Posted May 17, 2013 Share Posted May 17, 2013 (edited) I would suggest the following approach: #include <Word.au3> #include <Excel.au3> Global $oWordApp = _WordCreate("") Global $oDoc = _WordDocOpen($oWordApp, @ScriptDir & "\_Word_Test.doc") Global $oRange = $oDoc.Range ; select the whole document Global $vContent = $oRange.Copy ; Copy to the clipboard _WordQuit($oWordApp) $oExcel = _ExcelBookOpen(@ScriptDir & "\_Excel.xls") $oExcel.ActiveSheet.Paste Edited May 17, 2013 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
GhostLine Posted May 17, 2013 Author Share Posted May 17, 2013 Is there a way to determine a destination cell for the paste ? Link to comment Share on other sites More sharing options...
water Posted May 17, 2013 Share Posted May 17, 2013 (edited) Sure. Paste to cell B2: #include <Word.au3> #include <Excel.au3> Global $oWordApp = _WordCreate("") Global $oDoc = _WordDocOpen($oWordApp, @ScriptDir & "\_Word_Test.doc") Global $oRange = $oDoc.Range ; select the whole document Global $vContent = $oRange.Copy ; Copy to the clipboard _WordQuit($oWordApp) $oExcel = _ExcelBookOpen(@ScriptDir & "\_Excel.xls") $oExcel.ActiveSheet.Range("B2").Select() $oExcel.ActiveSheet.Paste Edited May 17, 2013 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
GhostLine Posted May 17, 2013 Author Share Posted May 17, 2013 Thank you so much Link to comment Share on other sites More sharing options...
water Posted May 17, 2013 Share Posted May 17, 2013 Glad to be of service My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now