Jump to content
Sign in to follow this  
Akshay07

Paste an image in Excel

Recommended Posts

Akshay07

I had a look in many of the _Excel functions, and I cannot find how to paste an image in Excel.

I could use some help :)

Share this post


Link to post
Share on other sites
Juvigy

$oExcel = ObjCreate("Excel.Application")
$oExcel.Visible = 1
$oExcel.WorkBooks.Open ($filename1)
$oExcel.Application.ActiveSheet.Paste

Try this , i havent tested it but it should work.

Share this post


Link to post
Share on other sites
Akshay07

$oExcel = ObjCreate("Excel.Application")
$oExcel.Visible = 1
$oExcel.WorkBooks.Open ($filename1)
$oExcel.Application.ActiveSheet.Paste

Try this , i havent tested it but it should work.

Thanks. Unfortunately, it doesn't work.

"Error: The requested action with this object has failed"

I also need to paste a picture into a specific cell.

Share this post


Link to post
Share on other sites
Juvigy

Does it work when doing it manually?

For the current cell try something like

$oExcel.Application.ActiveSheet.Range("B5").Sellect ; sellects B5

$oExcel.Application.ActiveSheet.CurrentCell.Paste

Also i hope you copied the picture before executing the script?

Share this post


Link to post
Share on other sites
Akshay07

Does it work when doing it manually?

For the current cell try something like

$oExcel.Application.ActiveSheet.Range("B5").Sellect ; sellects B5

$oExcel.Application.ActiveSheet.CurrentCell.Paste

Also i hope you copied the picture before executing the script?

Thanks for the tip for the cell selection. I think I know where the problem is. I am trying to copy a "small" window and then paste the image by simulating ALT and PRINTSCREEN key combination. But what is actually done is ALT, and then PRINTSCREEN, and as the image is then way too large, I can't paste it into excel.

So I need to check how to simulate ALT and PRINTSCREEN at the same time, or look into the help if a function allows an image capture of a specific window.

Share this post


Link to post
Share on other sites
Akshay07

For some reasons, the paste function works with

Send("^v")

but not with

$oExcel.Application.ActiveSheet.CurrentCell.Paste

Edited by Akshay07

Share this post


Link to post
Share on other sites
Juvigy

Try this :

$oExcel.Application.ActiveSheet.Paste

It doesnt paste the pic in the cell , though.

Share this post


Link to post
Share on other sites
Akshay07

Thanks, but the goal is to past the image in a specific cell.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×