Paste>Special Macro to Rule Them All

Joined
Feb 2, 2009
Messages
1
Reaction score
0
Hey guys,

I am new to the site as a member, but have been poking around here for a while. Anyways, I am trying to write a macro that does the following after a user has copied *something*:

  1. Try to paste the selection as a metafile (if it is an image)
  2. Try to paste the selection as un-formatted text (if it is a paragraph)
  3. Try to paste selection as value (if a formula)
  4. Return a simple error message if all else fails
I frequently have to paste Excel charts into word docs (hence the metafile option), paste blocks of text into a word template (from various sources), and paste excel values into word documents. Anyways, I had been successful in making two macros (one for text/numbers and one for charts/images), but I wanted to see if it was possible to combine the two.

Here is what I have so far:
Code:
On Error Resume Next
 	Selection.PasteSpecial DataType:=wdPasteEnhancedMetafile
 	Selection.PasteAndFormat (wdFormatPlainText)
 	If Err.Number <> 0 Then
 		MsgBox "Error Pasting Text:" _
 			& Chr(10) & "- Error #" & Err.Number & " " & Err.Description
 		ErrorRecord = 0
 	End If
 End Sub

Obviously, what that does is do both commands... Which isn't very helpful... How can I get it to discern whether it is just text or an excel chart that it is pasting, and then apply the appropriate paste option?
 

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