Sign in to follow this  
Followers 0
vivekvivek2001

Image pasting in Word

4 posts in this topic

I've been on this tool all morning and I'm impressed to see the amount of support this forum provides :)

Anyways,

Here's my problem (did a bit of googling but still couldnt find an answer :( ) :

While 1
If _IsPressed("1B", $dll) Then
MsgBox(0,"PrintScreener Terminated", "Thank you for using PrintScreener. Screenshots, if any, are present in D:\PrintScreener Screenshots\" & $s_f)
ExitLoop
ElseIf _IsPressed("2C", $dll) Then
_ScreenCapture_Capture("D:\PrintScreener Screenshots\Temp\Temp.png" , 0 , 0 , -1 , -1 , True)
Sleep(10)
$oShape = _WordDocAddPicture($oDoc , "D:\PrintScreener Screenshots\Temp\Temp.png" , 0 , 1 )
EndIf
WEnd

_WordQuit($oWordApp , -1)

What it does is it detects printscreen button press event, saves the clipboard content to a .png file and pastes the image in the .png file to the word document whose path has been mentioned in $oDoc.

1. It pastes the sequence of images backwards in the word file i.e., the last image taken is the first image you'll see and the last image in the word file is the first image you took. Cant this be reversed?

2. The above code works just fine but I noticed that the last screenshot taken appears twice in the word file. There's no problem with that being there but kinda like things perfect :P What am I doing wrong?

Share this post


Link to post
Share on other sites



  • Use my Function _Word_DocRangeSet allows to set the insertion point to the end of the document.
  • You have to insert a sleep after you have written the screenshot to Word because _IsPressed still returns True for x milliseconds. The help file states: "If the code called does not include a blocking function (such as MsgBox) and the user does not require multiple returns, the script should wait until _IsPressed() returns 0 before continuing.".

    The example in the help file describes how to do it right.

1 person likes this

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

Thanks....water??? :D

But weirdly enough the 2nd problem seems to have disappeared when I compiled it into an .exe file. Now I see only one image of the last screencapture (yay!)

I'll need to take a look at your methods in the UDF but thanks again :)

Share this post


Link to post
Share on other sites

Use

$oRange = _Word_DocRangeSet($oDoc, -2)
to move the insertion mark to the end of the document.


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

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