Copy Data From Excel Into a MSWord Document

D

dimm

Hi folks,

As a follow on to my previous question (Thanks again for the help)......I
want to copy and paste data from MS Excel into MS Word. Is this even possible
with VBA?

For example:

If I have text in cell B3, and I want to copy it into my MSWord document,
right justify it and format it to be Bold and Italic......then I want to
enter a space below this text in MS Word, and copy in the cell value from
cell A4 onto the next line of my Word document left justified?

Does that make sense....can I do this?
 
D

dimm

Thankyou, that helps a lot, but I have another question. John gives a macro
example for pasting into word as below from Excel, but what if the user has
another instance of Word open apart from my file (myfile.doc).

How do I specify that myfile.doc should be selected instead of any other
open word document?


' Reference existing instance of Word
Set WDApp = GetObject(, "Word.Application")
' Reference active document
Set WDDoc = WDApp.ActiveDocument
' Reference active slide

' Copy the range
Selection.Copy

' Paste the range
WDApp.Selection.PasteSpecial Link:=False, DataType:=wdPasteRTF, _
Placement:= wdInLine, DisplayAsIcon:=False

' Clean up
Set WDDoc = Nothing
Set WDApp = Nothing
End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top