Jump to content

Image pasting in Word


Recommended Posts

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?

Link to comment
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.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...