View Single Post
  #4   Report Post  
Old February 8th 18, 08:00 PM posted to microsoft.public.excel.misc
Terry Pinnell[_4_] Terry Pinnell[_4_] is offline
external usenet poster
First recorded activity by ExcelBanter: Aug 2015
Posts: 144
Default Pasting text into VBA macro?

GS wrote:

This recorded VBA macro inserts a specific picture into A22 and resizes
it to 85% of its original size.

Sub InsertPicture_Gf4()
ActiveSheet.Pictures.Insert( _

"C:\Users\terry\Dropbox\FinishedWalks\20170809Day0 2Trevone-Porthcothan-J-u502-red-m8.8-Gf4-Elev.jpg"
Selection.ShapeRange.ScaleHeight 0.85, msoFalse, msoScaleFromTopLeft
Application.CommandBars("Format Object").Visible = False
End Sub

But how can I edit that so that the filename
"C:\Users\terry\Dropbox\FinishedWalks\20170809Day0 2Trevone-Porthcothan-J-u502-red-m8.8-Gf4-Elev.jpg"
is replaced by whatever text is on the clipboard please?

Terry, East Grinstead, UK

I'm curious how the file path gets in the ClipBoard...

Hi Garry,

From a Macro Express Pro macro. I use a command to copy a variable
called FullTrackName (derived in earlier stages) to the clipboard.

I'm struggling to apply killme2008's advice. And would welcome some
further advice please. How exactly do I insert that specified JPG
picture at cell A30 of my (active) worksheet, TrackData-New.xlsm?

I was assuming it would be a relatively simple matter of replacing that
full filename with a line or two of code that would in effect PASTE it
into the simple macro I posted, and hence perform the insertion.

Terry, East Grinstead, UK