Sign in to follow this  
Followers 0
GhostLine

Inserting Word text (with pictures) in an Excel cell

10 posts in this topic

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



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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by GhostLine

Share this post


Link to post
Share on other sites

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

#6 ·  Posted (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 by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#8 ·  Posted (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 by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thank you so much :)

Share this post


Link to post
Share on other sites

Glad to be of service :D


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

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  
Followers 0