-            wx.TheClipboard.Open()
-            wx.TheClipboard.SetData(bmpdo)
-            wx.TheClipboard.Close()
-
-            wx.MessageBox(
-                "The bitmap is now in the Clipboard.  Switch to a graphics\n"
-                "editor and try pasting it in..."
-                )
+            if wx.TheClipboard.Open():
+                wx.TheClipboard.SetData(bmpdo)
+                wx.TheClipboard.Close()
+
+                wx.MessageBox(
+                    "The bitmap is now in the Clipboard.  Switch to a graphics\n"
+                    "editor and try pasting it in..."
+                    )
+            else:
+                wx.MessageBox(
+                    "There is no data in the clipboard in the required format",
+                    "Error"
+                    )