D
DA
Hi chead5,
There are no inbuilt VBA functions in Word that let you
probe the clipboard. To discover details about the
clipboard you need a call to the Windows API. The Windows
library that allows you to do this is "user32". It
contains a function called IsClipboardFormatAvailable,
which will in effect lets you probe which format is on
the clipboard.
To allow use of the function in VBA it has to be declared
in a module as follows (note, keep as one line):
Declare Function IsClipboardFormatAvailable Lib "user32"
(ByVal intFormatType As Integer) As Boolean
You can call the function and it will return True or
False depending if the format specified is available on
the clipboard. For example:
If IsClipboardFormatAvailable(2) Then _
MsgBox "Bitmap on the clipboard"
I don't think you'll be able to specifically determine if
your user has a powerpoint slide on the clipboard. I
think you'll get TRUE returns on both Bitmap and Metafile
formats.
Check the online MSDN for a full range of formats for the
function, but here's a few that you could use:
2 - Bitmap
3 - Metafile
8 - Device Independent Bitmap
14 - Enhanced Metafile.
As to your paste, you can do a PasteSpecial. For example:
Selection.PasteSpecial DataType:=wdPasteBitmap
Check your VBA help on PasteSpecial in order to find all
the available DataType formats.
Its also a good idea to place some error checking into
the paste event, especially when using PasteSpecial so
that you don't get caught out if trying to paste
unsupported formats.
Hope that helps,
Dennis
There are no inbuilt VBA functions in Word that let you
probe the clipboard. To discover details about the
clipboard you need a call to the Windows API. The Windows
library that allows you to do this is "user32". It
contains a function called IsClipboardFormatAvailable,
which will in effect lets you probe which format is on
the clipboard.
To allow use of the function in VBA it has to be declared
in a module as follows (note, keep as one line):
Declare Function IsClipboardFormatAvailable Lib "user32"
(ByVal intFormatType As Integer) As Boolean
You can call the function and it will return True or
False depending if the format specified is available on
the clipboard. For example:
If IsClipboardFormatAvailable(2) Then _
MsgBox "Bitmap on the clipboard"
I don't think you'll be able to specifically determine if
your user has a powerpoint slide on the clipboard. I
think you'll get TRUE returns on both Bitmap and Metafile
formats.
Check the online MSDN for a full range of formats for the
function, but here's a few that you could use:
2 - Bitmap
3 - Metafile
8 - Device Independent Bitmap
14 - Enhanced Metafile.
As to your paste, you can do a PasteSpecial. For example:
Selection.PasteSpecial DataType:=wdPasteBitmap
Check your VBA help on PasteSpecial in order to find all
the available DataType formats.
Its also a good idea to place some error checking into
the paste event, especially when using PasteSpecial so
that you don't get caught out if trying to paste
unsupported formats.
Hope that helps,
Dennis