Help! with code to open word

G

Guest

I need to write a macro that opens up word & copies a selection from the
excel file into the new word document pasted as "Picture (enhanced metafile)"
I am currently using excel 2003
 
T

Tyla

Something like this should get you started:

Sub copyRangeToWord()

Dim gobjWordApp As Object
Dim wdPasteMetafilePicture As Integer
Dim wdInLine As Integer

' Imitate Word constants
wdPasteMetafilePicture = 3
wdInLine = 0

' Create new Word session with a new, empty document
Set gobjWordApp = CreateObject("Word.Application")
gobjWordApp.Documents.Add
gobjWordApp.Visible = True

' Copy your source data to the clipboard
Activesheet.Range("A1:B17").Copy

' Paste it in Word
gobjWordApp.Selection.PasteSpecial Link:=False,
DataType:=wdPasteMetafilePicture, _
Placement:=wdInLine, DisplayAsIcon:=False

' Cleanup:
Set gobjWordApp = Nothing
Application.CutCopyMode = False

End Sub

HTH

/ Tyla /
 

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