Checking contents of clipboard before pasting

K

Kate Moncrieff

Hi,

I'm writing a Word VB macro to insert a metafile into a
Word document and reformat it.

When the macro is run, I want it to be able to tell
whether the clipboard currently contains an EMF picture.
If it does, I want the following statement to be executed:

Selection.PasteSpecial Placement:=wdInLine,
DataType:=wdPasteMetafilePicture

My question is: is it possible to check whether the
clipboard contains an EMF picture without actually pasting
the contents?

Thanks for your help!
Kate
 
L

Lars-Eric Gisslén

Kate,

Is this something you are looking for?
'-----------------------------------------------
Const CF_BITMAP = 2
Const CF_DIB = 8
Const CF_ENHMETAFILE = 14
Const CF_METAFILEPICT = 3
Const CF_OEMTEXT = 7
Const CF_TEXT = 1
Const CF_UNICODETEXT = 13
Declare Function IsClipboardFormatAvailable Lib "user32" _
(ByVal nFormat As Long) As Boolean


Sub ClipBoardData()

If IsClipboardFormatAvailable(CF_TEXT) Then
MsgBox "Text data found in the ClipBoard"
ElseIf IsClipboardFormatAvailable(CF_BITMAP) Then
MsgBox "Bitmap data found in the ClipBoard"
ElseIf IsClipboardFormatAvailable(CF_METAFILEPICT) Then
MsgBox "Metafile data found in the ClipBoard"
ElseIf IsClipboardFormatAvailable(CF_ENHMETAFILE) Then
MsgBox "Enhanced Metafile data found in the ClipBoard"
ElseIf IsClipboardFormatAvailable(CF_DIB) Then
MsgBox "Device Independent Bitmap data found in the ClipBoard"
ElseIf IsClipboardFormatAvailable(CF_OEMTEXT) Then
MsgBox "OEM Text data found in the ClipBoard"
ElseIf IsClipboardFormatAvailable(CF_UNICODETEXT) Then
MsgBox "Unicode Text data found in the ClipBoard"
Else
MsgBox "The Clipboard is propably empty or contains unknown data"
End If

End Sub
'------------------------------------

Regards,
Lars-Eric
 
K

Kate Moncrieff

Thanks Jeffrey. The problem's solved but I'm glad to know
about that site - looks like it could be useful.
Kate
 

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