Sign in to follow this  
Followers 0
telmob

_ClipPutFile in MS-Excel Possible?

13 posts in this topic

I've just done a little script to put some images in the clipboard and paste them mainly in Word and Excel (2010), but in Excel it doesn't work. The 'paste' button keeps greyed out.

Any chance to get this working?

Thanks!

Share this post


Link to post
Share on other sites



Do you past the clipboard to Excel using AutoIt or manually?

Which version of Excel do you use?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I paste manually. I only use Autoit to put the image to the clipboard.

I'm using Office 2010.

Share this post


Link to post
Share on other sites

I'm running Office 2010 too.

If I open Excel and press Ctrl+V the picture from the clipboard is copie to Excel without a problem.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Yes, if i copy the picture manually, it works (if i take a screenshot or something) but if i place a picture file in the clipboard with _ClipPutFile and paste it manually with a Ctrl+v it doesn't work.

Share this post


Link to post
Share on other sites

To insert a picture file into Excel you could use function _ExcelPictureInsert of the without the need to use the clipboard.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

The problem is that i made a tiny script (actually i spent quite some time on it yesterday) to place a predefined image to clipboard so i could paste it where ever i chose, but it doesn't work for excel.

So... i need the clipboard.

Edited by telmob

Share this post


Link to post
Share on other sites

Same problem here. Doesn't work with AutoIt 3.3.8.1 and 3.3.9.5 beta.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

I found this script by UEZ:

It's working, but i can't get it to work with an existing picture file.

Care to take a look?

I tried replacing the

$hBitmap = _ScreenCapture_Capture("", 10, 10, 300, 300, False)

With

$hBitmap = (@ScriptDir &"frame.png")

It should work, right?

Edited by telmob

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

How about this? Worjks fine for me here.

#include <Constants.au3>
#include <Clipboard.au3>
#include <ScreenCapture.au3>

Global $hBitmap, $hBitmap2, $hImage, $iResult
$hBitmap = _ScreenCapture_Capture("", 10, 10, 300, 300, False)
_ClipBoard_Open(0)
_ClipBoard_Empty()
_GDIPlus_Startup()
$hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)
$hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage)
$hImage = _GDIPlus_ImageLoadFromFile("C:temptest.png") ; <== Needs to be changed
_GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0)
$hBitmap2 = _WinAPI_CopyImage(_GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage), 0, 0, 0, $LR_COPYDELETEORG + $LR_COPYRETURNORG)
$iResult = _ClipBoard_SetDataEx($hBitMap2, $CF_BITMAP )
_ClipBoard_Close()
_WinAPI_DeleteObject($hBitmap)
_GDIPlus_ShutDown ( )

Func _WinAPI_CopyImage($hImage, $iType = 0, $xDesired = 0, $yDesired = 0, $iFlags = 0); from _WinAPIEx by Yashied
    Local $Ret = DllCall('user32.dll', 'ptr', 'CopyImage', 'ptr', $hImage, 'int', $iType, 'int', $xDesired, 'int', $yDesired, 'int', $iFlags)
    If (@error) Or (Not $Ret[0]) Then Return SetError(1, 0, 0)
    Return $Ret[0]
EndFunc ;==>_WinAPI_CopyImage
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

ahah, doesn't preserve transparency.... damn it! :blink:

Share this post


Link to post
Share on other sites

Then this is far over my head and you need to wait until UEZ jumps in :unsure:


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

I'm searching the forum for some possible solution, but the pasting is working ;) Thank you!

Shame it doesn't work using the normal _ClipPutFile. That would make things so much easier....

Edited by telmob

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  
Followers 0