Ghost_Line Posted May 17, 2013 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 !
water Posted May 17, 2013 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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Ghost_Line Posted May 17, 2013 Author 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
water Posted May 17, 2013 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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Ghost_Line Posted May 17, 2013 Author 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
water Posted May 17, 2013 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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Ghost_Line Posted May 17, 2013 Author Posted May 17, 2013 Is there a way to determine a destination cell for the paste ?
water Posted May 17, 2013 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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
water Posted May 17, 2013 Posted May 17, 2013 Glad to be of service My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
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