Excel export & create Word document 
Author Message
 Excel export & create Word document

Hi folks,

I am currently working with Excel VBA and wish to export a
particular range of data to create a new word document and
have this pasted into it thus creating a table.

I am using Office 2000 on Windows 2000

Any help greatly appreciated.

TIA

Sam



Tue, 16 Mar 2004 22:10:44 GMT  
 Excel export & create Word document
Hi Sam,

Well, in that case what *I* would do is insert a LINK field
into the Word document that contains the necessary worksheet
path and (named) range information. Rather than rely on
copy/paste over a VBA interface.

To see what I'm talking about: Copy a table in Excel, switch
to Word, and use Edit/Paste Special with a Link. Now press
Alt+F9 to display the field codes (this is like looking at
info in Excel's formula bar). You should see something like
this:
    { LINK Excel.Sheet.8 "E:\\My Documents\\MergData.xls"
"TestLinkedData!LinkData" \a \h }

So, what you need to pass from Excel is the path (with
doubled backslashes) and the worksheet!range.

For information on how you start up Word from within Excel,
see the mvps.org/word website. Once you have a document
opened or created, you do something like this:

ActiveDocument.Fields.Add _
    Range:=Selection.Range
    Type:=wdFieldLink
    Text:= "Excel.Sheet.8 " & """" & _
        "E:\\My Documents\\MergData.xls" & _
        """" & " " & """" & _
        "TestLinkedData!LinkData" & """" & " \a \h"
    PreserveFormatting:=True

Quote:
> I am currently working with Excel VBA and wish to export a
> particular range of data to create a new word document and
> have this pasted into it thus creating a table.

> I am using Office 2000 on Windows 2000

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister
http://www.mvps.org/word
http://go.compuserve.com/MSOfficeForum

This reply is posted in the Newsgroup; please post any follow
question or reply in the newsgroup and not by e-mail :-)



Thu, 18 Mar 2004 00:28:56 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Export to MS Word & MS Excel problems

2. Creating Word Document from templates linking excel files

3. create a link to a excel, power point, word document

4. Creating Word documents from an Embedded OLE Word Template

5. How to export an access table to an excel document

6. How can i export diagrams to word document in Visual basic

7. Export Word document to custom format

8. Exporting Access query to Word Document

9. Export Word-document with pagenumbers

10. Can't edit exported Word document

11. Export to Word document

12. Facing Problems Exporting CRYSTAL REPORTS TO WORD DOCUMENTS.

 

 
Powered by phpBB® Forum Software