Jump to content
Sign in to follow this  
GhostLine

Inserting Word text (with pictures) in an Excel cell

Recommended Posts

GhostLine

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 !

Share this post


Link to post
Share on other sites
water

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 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
GhostLine

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 by GhostLine

Share this post


Link to post
Share on other sites
water

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 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
GhostLine

Yes sir :) I especially format the Word file to fit onto the Excel cell.

Edited by GhostLine

Share this post


Link to post
Share on other sites
water

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 by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
GhostLine

Is there a way to determine a destination cell for the paste ?

Share this post


Link to post
Share on other sites
water

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 by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
GhostLine

Thank you so much :)

Share this post


Link to post
Share on other sites
water

Glad to be of service :D


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×