PasteSpecial & enhanced metafile not working

S

snaapy

Hi,

I am trying to copy an object from Visio and paste it to Word using
Visual Basic scripting. I want the copied object to be pasted as an
enhanched metafile. No matter what I use as a destination data type,
the object ends up be pasted as an embedded Visio object.

Manual pasting works fine.

Is there a workaround for this?

My code:


Sub DoCopyPaste()

' Get Running Microsoft Word
Set wordApp = GetObject(, "Word.Application")

' Get Running Microsoft Visio
Set visioApp = GetObject(, "Visio.Application")

If wordApp = Nothing Then
Debug.Print "No Microsoft Word open"
Return
End If

' Copy selected object in Visio
visioApp.ActiveWindow.Selection.Copy

' Paste object in Word
wordApp.Selection.PasteSpecial Link:=False,
DataType:=wdPasteEnhancedMetafile, _
Placement:=wdFloatOverText, DisplayAsIcon:=False
 
D

David Parker

If you are programming with the Visio object model, then you can save the
selected shapes as an EMF file and then import it into Word, therefore
avoiding cut'n'paste...
 
J

JuneTheSecond

I tryed your code on Excel VBA, and it worked well to paste Visio shape as
WMF onto Word. A little moddification is, "If wordApp Is Nothing Then"
inplace of "If wordApp = Nothing Then", or "Is" in place of "=".
If pasted as WMF, it is now not a Visio object. If you wish that the pasted
object remains a Visio object, you are recommended to paste as an Visio
object for example;
wordApp.Selection.PasteSpecial Link:=False, DataType:=wdPasteOLEObject,
Placement:=wdInLine, DisplayAsIcon:=False
 

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