• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA to copy from excel and paste in word

deenoseban

New Member
Hi,

I am trying to copy a range from excel and paste it as an image in word file, able to copy and open my word file but somewhere am getting an error and not able to paste.

>>> use code - tags <<<
Code:
Sub myexcel_to_word ()
Dim mytbl As Excel.Range
Dim WordApp As Object
'this code copy my dynamic range in excel
Set mytbl = Range(("A7"), ActiveCell.SpecialCells(xlLastCell))
  mytbl.Copy
   
'this code opens my letterhead from my desktop
    Set WordApp = CreateObject("word.Application")
    WordApp.Documents.Open "C:\Users\dss\Desktop\Invoice_Generate\Letterhead.docx"
    WordApp.Visible = True
  'this code paste the data as image in word, but....     
Selection.PasteSpecial Link:=False, DataType:=wdPasteEnhancedMetafile, _Placement:=wdInLine, DisplayAsIcon:=False
   
End Sub
 
Last edited by a moderator:
Try:
Code:
Sub myexcel_to_word()
Dim mytbl As Excel.Range
Dim WordApp As Object
'this code copy my dynamic range in excel
Set mytbl = Range(("A7"), ActiveCell.SpecialCells(xlLastCell))
'mytbl.Copy
mytbl.CopyPicture Appearance:=xlScreen, Format:=xlPicture 'you can also test the original line above instead.
'this code opens my letterhead from my desktop
With CreateObject("word.Application")
  .Documents.Open "C:\Users\Public\Documents\Letterhead.docx"
  .Visible = True
  .ActiveWindow.Selection.Paste
End With
End Sub
 
Try:
Code:
Sub myexcel_to_word()
Dim mytbl As Excel.Range
Dim WordApp As Object
'this code copy my dynamic range in excel
Set mytbl = Range(("A7"), ActiveCell.SpecialCells(xlLastCell))
'mytbl.Copy
mytbl.CopyPicture Appearance:=xlScreen, Format:=xlPicture 'you can also test the original line above instead.
'this code opens my letterhead from my desktop
With CreateObject("word.Application")
  .Documents.Open "C:\Users\Public\Documents\Letterhead.docx"
  .Visible = True
  .ActiveWindow.Selection.Paste
End With
End Sub

Hi dude,

You are a savior...
I remember the last time, your code helped me.

Thank you so much
 
Back
Top