View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Martin Krastev[_2_] Martin Krastev[_2_] is offline
external usenet poster
 
Posts: 20
Default Working between XL and Word

1. To paste as plain text use Selection.PasteAndFormat (wdFormatPlainText)
and to paste as table use Selection.PasteAndFormat (wdPasteDefault)
2. Yes, the type library reference is kept with the excel workbook

"Francis Hookham" написа:

Many thanks Lonnie and Martin

Ok as far opening the Word doc but I am having no luck with pasting in the
copied table

1 In this particular case I want the table pasted in but, in the future,
I might want to paste as text so can you help with code for both please

2 Is the reference to 'Microsoft Word Object Library' carried by the
macro/worksheet of shall I have to set the reference again in another
computer - I shall want to send the resulting worksheet to a friend for whom
I am writing this

Thanks

Francis Hookham

Sub PasteAsPic()
Dim WrdApp As New Word.Application
Dim wrdDoc As New Word.Document

'copy the required data from the Excel File
ThisWorkbook.Sheets(1).Range("B2:D10").Copy

' Create a new Word Document
Set wrdDoc = WrdApp.Documents.Add(DocumentType:=wdNewBlankDocum ent)
WrdApp.Visible = True

'Paste the copied data as Picture
WrdApp.Selection.PasteSpecial Placement:=wdInLine,
DataType:=wdPasteBitmap

'save the new Word Document
wrdDoc.SaveAs "c:\Filename.doc", wdWord

'clean up code
wrdDoc.Close
Set wrdDoc = Nothing
Set WrdApp = Nothing

End Sub



"Lonnie M." wrote in message
ups.com...
Here are a couple of examples that might help you get started.

Example of pasting to a new Word document:
http://groups.google.com/group/micro...cd865d50a7b808


Example of opening and pasting to the Word document:
http://groups.google.com/group/micro...c733e1036c0ba0

HTH--Lonnie M.