How to copy a named range into Paint?

Chris Williamson

Board Regular
Joined
Oct 16, 2010
Messages
83
Hi guys,</SPAN></SPAN>

Can somebody please help me with this little task that I’m stuck with?</SPAN></SPAN>

What would the vba macro code be to:</SPAN></SPAN>

  1. Select the named range “S_Shot”</SPAN></SPAN>
  2. Copy this range to the clipboard (Ctrl + C)</SPAN></SPAN>
  3. Open the application “Paint”</SPAN></SPAN>
  4. Then paste the copied range into Paint.</SPAN></SPAN>



This is the code that excel recorded for the first two steps.</SPAN></SPAN>

Sub Macro1()</SPAN></SPAN>
Application.Goto Reference:="S_Shot"</SPAN></SPAN>
Selection.Copy</SPAN></SPAN>
End Sub</SPAN></SPAN>


Thanks for your help

Chris
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Try this out. I am suggesting using SendKeys to give you the paste option

HTML:
Sub CopyToPaint()
Dim vetral As String
Range("The cells").Copy
vetral = Shell("msPaint.exe", vbNormalFocus)
Application.SendKeys ("^V")

End Sub
 
Upvote 0
Sligth change you need to use the delay before it will paste into Paint.

HTML:
Sub CopyToPaint()
Dim vetral As String
Range("D4").Copy
vetral = Shell("msPaint.exe", vbNormalFocus)
Delay 3
Application.SendKeys "%ep"

End Sub
Private Sub Delay(sec)
Dim newHour   ' = Hour(Now())
Dim newMinute ' = Minute(Now())
Dim newSecond ' = Second(Now())
Dim waitTime  ' = Delay time in Secs
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + sec
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
End Sub
 
Upvote 0

Forum statistics

Threads
1,203,760
Messages
6,057,202
Members
444,913
Latest member
ILGSE

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top