I finally got this macro working. With the full filename of a JPG image on the clipboard, it insers that as a picture in the active worksheet:
HOWEVER, it will only work if I place it in Personal.xlsb. If I put it in the worksheet in which I want to work, TrackData-New.xlsm, I get this error: "Compile error: User-defined type not defined".![]()
Sub InsertPicture_Gf4() ' Dim MyData As DataObject Dim strClip As String Set MyData = New DataObject MyData.GetFromClipboard strClip = MyData.GetText Range("A30").Select ActiveSheet.Pictures.Insert(strClip).Select Selection.ShapeRange.ScaleHeight 0.85, msoFalse, msoScaleFromTopLeft Application.CommandBars("Format Object").Visible = False Rows("27:27").Select End Sub
I did observe the obscure instruction I had found, namely that for this to work you must "Have at least one UserForm in your project".
ClipMacroNotWorking.jpg
Anyone know the reason for this failure and how to fix please?
Bookmarks